As you are a novice, perhaps you have not grasped UNIX pathing: file locations can be relative to your current directory $PWD, initially $HOME where you log in, but also absolute (starting with /). You can go anywhere with either, but in $PWD you must go up-tree with ../../../ to get near enough to / to start back down the tree.
Start by doing ls -ld on the path components, so if $1/$file1 is /x/yy/zzz.txt, do:
to see the directory permissions and file permission. It is columns 2-7. All permissions is rwxrwxrwx or in octal, 777. The first digit/rwx is for you, the second digit is for the file's group (type id to see yours), and the third digit is for others. Here is my home directory, 755, I (dgp) can do all three but group develop and others can only read and execute (in directories, execute means search/traverse but not display=r read, i.e., permission to go downstairs but not to look around)
ok thanks for your help. Just still one thing I am not grasping. is in my directoy I can execute the script, which is called "dirfile".
so when I go dirfile test test2
(test and test2 are directory names)
the script will execute and list the files that are different, but when I go to my teacher's directory and type " dirfile test test2", it tells me "If 'dirfile' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf dirfile"
So is there anyway to make this script run in any directory even it the script is not located there?
Changing directory means any files, including executable files, in the old dir are no longer available without a prefix. If you were and /a/b/ and run c, which is /a/b/c, then when you change dir to /a/d/e/, you need to call c as /a/b/c or ../b/c (because /a/ is common, and .. /../ is /a/ when you are in /a/d/e/. I put / on the end of all directory references, for clarity, but you do not need to add them. cd /a/d/e and cd /a/d/e/ both take you to pwd = $PWD = /a/d/e
thanks that worked, now my program runs perfectly using absolute pathnames. But when I run the script like this it doesnt work.
cd ~/user/120/dir1(I go into this directory)
dircompare . ~/user/120/dir2
dircompare is the name of the script. So what I am doing is going into a directory and using . to represent my current directory and then the absolute path to the second directory. The script prints out the first directory files fine but the second directory files dont out the right file. Any idea whats wrong?
output when using absolute pathnames:
output when using . and absolute:
there has to be something wrong with this code for the dot but i don't know what.
The parentheses mean the cd moves a subshell but not the parent shell. If you
with relative paths, you are not in dir2, you are in dir1/dir2 -- you are digging down an imaginary tree. Even with absolute paths, for repeatability, it is nice not to move from the starting $PWD. If you
, you have not moved.
Hi,
I want to display the file names and the record count for the files in the 2nd column for the files created today.
i have written the below command which is listing the file names. but while piping the above command to the wc -l command
its not working for me.
ls -l... (5 Replies)
I'm looking for a script which outputs the list of directories and sub directories from root level consisting of specific files. For instance I want shell script to list all the directories and subdirectories containing .txt files.:wall: (4 Replies)
Hi,
I came up with this question in one of the exercises .
Use find to produce a long ls listing of all files in /usr/bin that are
more than 750Kb long. You’ll need to use a form like
find ..... -exec ls -l {} \;
The semicolon must be escaped, but not the .
I tried using below code ,... (1 Reply)
Hi,
I have to list the files in a particular folder which are having file names like below:
1000_aa.csv, 1000_ab.csv, 1000_az.csv,1000_ba.csv,1000_bb.csv,1000_ca.csv,1000_cb.csv.
How can i get the list?
Thanks,
Selva (2 Replies)
Hi,
I am new to perl:
I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory.
advanced thanks for valuable inputs.
Thanks
Prakash GR (1 Reply)
Hi there!
I would like to list all the files from a directory and its subdirectories. For example:
DIRECTORY
|- SUBDIR1
||- sub1.txt
||- sub2.txt
|- SUBDIR2
||- sub3.txt
|- root1.txt
|- root2.txt
I would like to create a fulllist.txt file which contains the list of these files (with... (2 Replies)
I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file.
Sample control file:
TEST
SEND
SFFFILE
CONTL
The directory contains followign... (15 Replies)
hi,
i have a the direcories like
usr\clone1\heap001.txt
usr\clone2\heap334.txt
usr\clone3\heap8899.txt
i nead a command which list all the file starting with heap*.i have to execute the command from usr directory. find command is hanging, i need some other form of script to do ... (2 Replies)
Hi,
I need to write a script,which behaves like this,
Given the folder name, it should list the files with today's timestamp.
Please direct me on this.
Thanks. (2 Replies)
Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories.
The following command also shows the files but I only want to see the directories.
ls -lrtR * (4 Replies)