What command can search for a specific file in my home directory? - unix

Writing a beginner shell script and it's asking for to locate and verify if a file under a specific name is located within my home directory but I'm not sure what command would best fit that.

To find any file in linux, use this command:
find . -name file_name
point means current directory
you can change it to /home/
thanks

Related

Winzip command line - Include full path information

How do I use winzip command line with include full path information ? I know I can do this under Winzip GUI but how to do it using cmd ? Also, is there a way to zip selected specific folders only ? Thanks
Tried GUI and it is working very slow
Winzip command line doesnt seem to zip selected folders - either parent folders or specific subfolders
I am using winzip 27 command line and this is the syntax I am using:
wzzip -a -e0 -k -P -r -yx "C:\Users\source\to\save\zipfile.zip" "C:\example"
This stores files and folder timestamps underneath C:\example. But since I have enabled -P -r, I want to store the timestamps of the upper folder, C:\example folder. How can I do that ? Does anyone have suggestions?
Also, how do I specify the path for a mapped network drive? Thanks!

Creating a terminal command in Minix

I want to create a command that runs an executable created by compiling a c program. I couldn't find a proper solution. Let's say I have a file named myprogram.c and compile it and have myprogram as . I want to type myprogram in any folder in my system and run it. How can I achieve this?
First find out what your PATH is
echo $PATH
For you this outputs
/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin/usr/X11R7/bin:usr/X11R‌​‌​6/bin:/usr/local/sbin:/usr/local/bin
Then assuming your program is in the /usr/myprog directory, append /usr/myprog to your PATH (don't forget to separate directories with a colon :)
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin/usr/X11R7/bin:usr/X11R‌​‌​6/bin:/usr/local/sbin:/usr/local/bin:/usr/myprog
Doing this tells the system when you don't specify an absolute path (like ./myprogram) to look in all the directories in PATH. It is good to add the absolute path of your executable to PATH because adding . to your PATH is frowned upon by some (see this question).
You have to add it in your PATH from your shell rc file
You place the executable into a directory that your shell already searches for programs, or you add your program's location to that list.
the $PATH environment variable contains this information. You can add myProgram's location to it, i.e. export PATH=$PATH:/new/dir, or just print out $PATH and copy myProgram into one of the paths listed there already.

Intro. Unix: Changing Directories

I started an online Unix course. I entered the course kinda late and I'm having a little trouble getting caught up. We had a homework question (I got it wrong) it said to:
Change the current working directory to directory WT5 using a single command line and starting at the home path.
How in the world am I supposed to do that? I know how to change a directory from your current directory just $ cd WT5 And if I wanted to list all of the contents in the home directory I would use $ ls ~/nameofhomedirectory And, if I wanted to change the current working directory to the home directory I would use $ cd ~ or just $ cd
So how would I combine all of that in one single command line to change the current directory to another directory using a path that includes the home directory?
Thank you for all of your help in advance!
UPDATE: Okay. I can see now that this maybe a little confusing. So let me try to make it a little bit more clear where I am going wrong or getting mixed up.
Let's say this is a tree of directories you have.
Tree of Directories
Now, your home directory is user And your current working directory is work But you want to change your current working directory to play. How would you change the directory using a single command line and starting at your home direcotry and not your current working directory work
Thanks again!
I'm not quite sure I understand your question, but you could try:
cd ~/WT5
or:
cd $HOME/WT5
or if you absolutely need to be long-winded about it:
cd /user/homedirectory/subdirectory/currentworkingdirectory/WT5
These all include your home directory in the path. The short-hands are to be preferred.
This might do the trick:
cd ~/../users/carol/play
The idea is that you can go upwards from a home directory too.

Seemingly invalid No such file or directory error

I'm attempting to open a directory in Unix. If I enter the command
ls
I see the directory listed in my current directory but if I endter
cd [directory_name]
I get the error
No such file or directory
I'm also not able to auto complete the directory name using the 'tab' key. Does anyone know what may be causing this?
Check whether you are using the right capitalization? It's case sensitive. Add this to your ~/.inputrc if you want bash to not care about the case of the file.
set completion-ignore-case on
This is example:
user#stackoverflow:~$ ls
users questions file.txt
user#stackoverflow:~$ cd /questions
user#stackoverflow:~/questions$
Make sure that you're trying to access a valid folder and not a file.
To further explain:
List the current directory's contents (either one):
ls .
ls
List the home directory's contents (wherever you are):
ls ~
List the root directory's contents (wherever you are):
ls /

Unix locate command for present working directory

The locate command in Unix will return the path related to the attribute given (for example, locate abc_file). What is the command to locate a file in the present working directory structure?
If you use wildcards (as *) locate considers the pattern to be an absolute path. Therefore you could e.g. do:
locate "$PWD*/abc_file"
This will find all files abc_file under your $PWD and its subfolders (as long as they are in the locate database).
On the other hand you can also always use oldschool find:
find . -name abc_file

Resources