Just listing size, timestamp & name of files in a directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Just listing size, timestamp & name of files in a directory
# 1  
Old 01-25-2010
[Answered] Just listing size, timestamp & name of files in a directory

How can I list the files in a directory and just show the file size, date stamp, timestamp and file name..

I've been trying to ls -lrt the directory to a file and then use the cut command but I'm not having any luck with getting the proper results.. I thought i could use the -f switch and count the number of columns i needed but its not giving me what i need..

Any suggestions..

Last edited by Jazmania; 01-25-2010 at 02:24 PM..
# 2  
Old 01-25-2010
Please post your code.
# 3  
Old 01-25-2010
[Answered] Just listing size, timestamp & name of files in a directory

I have a txt file with the contents of the folder in it.. I used ls -lrt > rcode_folder.txt so the file looks like this..

-rw-r----- 1 jazmania dba 787510 Jul 26 2004 code.r

I just want the 787510 Jul 26 2004 code.r part to show in the file



I then tried to use the below cut command but i'm not sure if i'm using the -f part right...

Code:
cut -f 5-9 -d ' ' ./rcode_folder.txt > formated_rcode.txt


Last edited by Jazmania; 01-25-2010 at 02:22 PM..
# 4  
Old 01-25-2010
Cut dont work since data has mutiple spaces. Try awk
Quote:
awk ' { print $5,$6,$7,$8,$9 } ' ./rcode_folder.txt > formated_rcode.txt
# 5  
Old 01-25-2010
Nice one, that works just fine..

Thanks for your help..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory listing in the order of size

I want to display directory listing in the order of size. I do not have -S option in my version of UNIX. So I wrote a simple script. But it takes "| sort -n -k5,5" part as file names. Any suggestion? #!/bin/ksh cmd='ls -l *.TXT | sort -n -k 5,5' set -x $cmd return 0 (7 Replies)
Discussion started by: Soham
7 Replies

2. Shell Programming and Scripting

Listing of files between two timestamp

Hi, I want to list down the files between two timestamp. But I can not use newer or newermt command as it doesn't support these tokens. Is there any other way to achieve this? Else I have to write too much of coding . Input Dec 01 02:02 Dec 02 05:07 (8 Replies)
Discussion started by: Abhijit Sen
8 Replies

3. Homework & Coursework Questions

Listing the files in a directory

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A script that takes any number of directories as command line arguments and then lists the contents of each of... (3 Replies)
Discussion started by: Phaneendra G
3 Replies

4. Shell Programming and Scripting

Listing latest & large files from a mounted drive

Hi All, My AIX server have a mounted drive "/stage". I want to list the latest modified/created files in this drive. Also large files in this drive. I tried to ls -l | sort +4nr | head -10 Someother solutions to list from entire drive. Thanks. :) (6 Replies)
Discussion started by: karumudi7
6 Replies

5. Shell Programming and Scripting

How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir (0 Replies)
Discussion started by: shaal89
0 Replies

6. UNIX for Advanced & Expert Users

Block size in listing files

I see the following in my prompt... that is, i have only one file but i see 8 as total. /home/asla>ls -l total 8 -rw-r--r-- 1 oracle dba 6 Oct 17 18:59 simple Can you please tell me why that 8? I checked different sources they say it is number of blocks but in this case... (7 Replies)
Discussion started by: shahnazurs
7 Replies

7. UNIX for Dummies Questions & Answers

listing files in a directory in bases of size

Hi , I want to list all files in the order of size . Just want to know which files occupies more size and which occupies less size . Is it possible with ls command ? :) Thanks, Arun. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

8. UNIX for Dummies Questions & Answers

Timestamp in directory listing

Hi, I need a help. I want to see all the files in the directory with the Time Stamp. I use the following command. $ls -lt This displays the files with time stamp, but not all the files. Only last few months, the files are displayed with timestamp, the old files are only have dates. ... (2 Replies)
Discussion started by: vijashok
2 Replies

9. Filesystems, Disks and Memory

Sun UNIX Files & Folders listing

Hi guys, i'm new to UNIX and only know a small amout about it, but have just had some changes at work which now require me to interact with and work on SUN Unix systems often. I have reasonable knowledge of PC's but hope that you will be able to help me with these questions. Part1. I would like... (3 Replies)
Discussion started by: Scrat
3 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