Listing files in a particular format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listing files in a particular format
# 1  
Old 08-23-2011
Listing files in a particular format

Hi,

My unix version is as follows:

Code:
uame -a

HP-UX server-name B.11.11 U 9000/800 2329770924 unlimited-user license

I just want to get file listing is a particular format listed below.

Code:
name  permission set(octal)  size  date (mon dd, yyyy)

I am trying to use the following command.

Code:
ll | egrep -v '^d' | awk '{ printf "%-29s\t\t%s\t%5s\t\t%s %s,%s\n", $9,$1,$5,$6,$7,$8 }'

But its giving me output like follows-

Code:
a.out                                   -rw-------          0           Aug 5,06:55

While the required output is

Code:
a.out                                   600          0           Aug 5, 2011

Also its giving me a 'total' line in the beginning while using above given command. I also don't want that line in my output.

Please help me achieve output in desired format.

Many thanks,
Manu
# 2  
Old 08-23-2011
Code:
ll | awk ' !/^d/ { if(NR>1) {printf "%-29s\t\t%s\t%5s\t\t%s %s,%s\n", $9,$1,$5,$6,$7,$8} }'

better to post your ls command output and the required output format
This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 08-23-2011
Thanks.

Your code removed the first line, where total blocks are written.

Please also help me achieving file creation date in mon dd, yyyy format instead of mon dd hh:mm format.

Thanks.
# 4  
Old 08-23-2011
A clue to get the year!,

if the file is created on the current year, then the file timestamp will be shown in hh:mm format.

So, try something like this:

Code:
 
ls -l | awk '{$(NF-1)=$(NF-1)~/:/?"2011":$(NF-1);print}'

You have to add the above code in your requirement.
# 5  
Old 08-23-2011
Hi Panyam,

Thanks for your consideration.

But it's not always true, that if file is created only in the current year, then only time will be show.

Consider the case that today is "2nd Jan 2011", and file is created on "29th Dec 2010". Year has been changed since the time of file creation (2010 to 2011). But still it will show the date in dd mon hh:mm (29 Dec 3:54) format. Kindly consider this case as well.

Regards,
Manu
# 6  
Old 08-23-2011
Manu,

If you post the ls command output and the required output format, then you can get answers soon.

Always give the clear input and output format. Smilie
# 7  
Old 08-23-2011
Hello,

I'm sorry I did not read it fully. Indeed, it's not creation time but modified time.

man ls , gives

Code:
 
If the time of last modification is greater than six months ago, or any time in the future, the year is substituted for the hour and minute of the modification time.

So, need to find a logic here to get the years!!!.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate HTML output format listing like orasnap

Hi, Is there any UNIX scripts out there that generates a listing output of some sort similar to OraSnap At the moment, I have a script that I run on multiple servers that has multiple databases and just querying the database sizes of those databases. It generates a text files that contains... (0 Replies)
Discussion started by: newbie_01
0 Replies

2. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

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)
Discussion started by: Showdown
5 Replies

3. UNIX for Dummies Questions & Answers

How to find directory listing from root to all files in tree format with details of perm/own/grp?

Hi, My apologies if my query is already available on this forum but I am new and could not find. I need a script to list all directories/sub directories and files with permissions/groups/owners. The script would run from home directory and should capture every directory. How do I do this? ... (4 Replies)
Discussion started by: 8709711
4 Replies

4. Shell Programming and Scripting

Need script for transferring bulk files from one format to text format

"Help Me" Need script for transferring bulk files from one format to text format in a unix server. Please suggest (2 Replies)
Discussion started by: Kranthi Kumar
2 Replies

5. Shell Programming and Scripting

modify ls -l (long listing format output) strictly using SED only straightforward goalhard 4 me doh

Below is a sample out of ls -l which I would like to rearrange or modify by field numbers for example I successfully managed to disect using simple paragraph however for ls -l I can't divide the rows or fields by field number. Successful modification by fields using SED sample: $ sed -e... (1 Reply)
Discussion started by: wolf@=NK
1 Replies

6. Shell Programming and Scripting

perl script for listing files and mailing the all files

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)
Discussion started by: prakash.gr
1 Replies

7. UNIX for Advanced & Expert Users

listing files excluding files from control file

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)
Discussion started by: ukatru
15 Replies

8. Shell Programming and Scripting

listing file with other format

Hello. If i use ls to list file, the output will be like this: ls list* list1.txt list2.txt list3.txt list4.txt list5.txt How can I list file like below (I tried to us ls -ltr list*.txt, but all of them with time, date in font of the file...but I don't need it)? list1.txt... (3 Replies)
Discussion started by: happyv
3 Replies

9. Shell Programming and Scripting

Listing filesnames in bare format with fullpath

Hi, Need help. How can I get a listing of files in bare format with full path. I mean in the following format. /root/dir1/sub-dir1/file1 /root/dir1/sub-dir1/file2 /root/dir1/sub-dir2/file1 /root/dir1/sub-dir2/file2 /root/dir2/sub-dir1/file1 /root/dir2/sub-dir2/file1... (2 Replies)
Discussion started by: tipsy
2 Replies

10. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

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)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question