To read directories and file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To read directories and file
# 1  
Old 07-20-2011
To read directories and file

Hi ;
I want to write a shell script to read all files and directories(recursively) given in path along with their user permissions and store that result in one file as
File path Userpermissions
===== ===========

I m new to linux and my dont kno much abt shell scripting.
I will appreciate if nebody help me out in getting through this.

Thanks;
Ajay
# 2  
Old 07-20-2011
How about this ?
Code:
 find . | xargs ls -l | awk '!/^\./ && !/^total/ && !/^$/{print $1,$NF}'

# 3  
Old 07-20-2011
Tools Redirect files permision to a file

Code:
echo "File######User#####Permission" >File.txt;
echo "===============================================" >>File.txt;
ls -ltr | awk -F' ' '{if($1 == "total" ){}else{print $8"####"$1"####"$3;}}' >>File.txt

Cheers,
RangaSmilie

Moderator's Comments:
Mod Comment Please start using [CODE] tags when posting source listings, console output, ...

Last edited by pludi; 07-20-2011 at 04:45 AM..
# 4  
Old 07-20-2011
Hi;
thanks for the reply.
I have one problem though.For those files having spaces in their filename,commands are not working properly.
Is der any proper way by which one can do this formating using awk to accept filename containing spaces too in listing.
Thnks again,
# 5  
Old 07-20-2011
Code:
 
find . -type f -ls | nawk '{for(i=11;i<=NF;i++){printf("%s ",$i)} {print $3}}'

# 6  
Old 07-20-2011
Thank u for all buddies..Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies

2. Shell Programming and Scripting

For loop and read from different directories

Hello, I need to grep/read files from multiple directories, one by one. I mean something like shuffling the cards uniformly. cd /directoryA for i in *.txt; do some codes cd ../directoryB for i in *.txt; do some codes cd ../directoryC for i in *.txt; do some codes done done... (8 Replies)
Discussion started by: baris35
8 Replies

3. Shell Programming and Scripting

Read directories sequential based on timestamp

Hi, I have a directory structure like below Directoryname create time d1 12:00 d2 12:05 d3 12:08 I want to read the directories based on timestamp.That is oldest directory must be read first and kick off certain process. ... (7 Replies)
Discussion started by: chetan.c
7 Replies

4. UNIX and Linux Applications

Perl Script to read an excel file into an array and search in the UNIX directories

Hi, I want the Perl script with versions 5.8.2 and 5.8.5 starting with #!/usr/bin/perl The Perl program should read the excel file or text file line by line and taking into an array and search in the UNIX directories for reference file of .jsp or .js or .xsl with path .The Object names... (2 Replies)
Discussion started by: pasam
2 Replies

5. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

6. Shell Programming and Scripting

Perl: Read directories and assign to array

I would like to read directories and assign to an array where the user can select a directory from the output. For example, a dir list will populate with a number assigned to each dir. I would like to ask the user to select the dir they want. TIA, I don't know what this would be called so I... (2 Replies)
Discussion started by: man
2 Replies

7. UNIX for Dummies Questions & Answers

Copy file into directories and sub-directories

Hello- I need to copy a file into multiple directories, and each directory's sub-directories (of which there are 5) Currently, the parent directory is set up like this: dir1 sub-dir1 sub-dir2 sub-dir3 sub-dir4 sub-dir5 dir2 sub-dir1 sub-dir2 sub-dir3 ... (1 Reply)
Discussion started by: penlok
1 Replies

8. Shell Programming and Scripting

Bash Script to Read & Write on different directories

Hi, root@server] df -h 121G 14G 101G 12% /home 147G 126G 14G 91% /backup We having our site files and images are storing in /backup/home/user/files/ through symbolic link created in /home directory pointing in /backup directory as following. root@server] cd /home... (1 Reply)
Discussion started by: mirfan
1 Replies

9. Shell Programming and Scripting

read list of filenames from text file and remove these files in multiple directories

I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions , to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like... (5 Replies)
Discussion started by: fxvisions
5 Replies
Login or Register to Ask a Question