Extracting only file size of the ls -ltr command.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extracting only file size of the ls -ltr command.
# 1  
Old 05-10-2007
Extracting only file size of the ls -ltr command.

All,

I only need to get the file size when I do an ls -ltr filename.txt

Could you give me the exact syntax.

Thanks
KOP
# 2  
Old 05-10-2007
See if this would work for you
Code:
du -a | sort -n

# 3  
Old 05-10-2007
Code:
ls -lrt | nawk '{print $5}'

# 4  
Old 05-10-2007
I had earlier used

du -sk Filename.txt

The output was ===>

3 Filename.txt

I have to only output 3 not the filename.


Thanks
KOP
# 5  
Old 05-10-2007
Try this:
Note that <tab> is the one character tab (control-i, hex 09, octal 011).
Code:
du -a | sed 's/<tab>.*//' | sort -n

# 6  
Old 05-13-2007
Quote:
Originally Posted by kingofprussia
I had earlier used

du -sk Filename.txt

The output was ===>

3 Filename.txt

I have to only output 3 not the filename.


Thanks
KOP
Code:
# set -- $(du -sk filename)
# echo $1
3

# 7  
Old 12-03-2007
File Size

You can try this command as well

ls -ltr <filename> | cut -c 32-43
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Generic script to load file details(ls -ltr) in to a database.

All, I am trying to create a report on the duration of an ETL load from the file arrival to the final dump in to a database for SLA's. Does anyone have any guidance or ideas on how metadata can be extracted; information of a file: like file name, created timestamp, count of records and load... (1 Reply)
Discussion started by: pradeepp
1 Replies

2. Shell Programming and Scripting

I have two commands “ls -h” and “ls -ltr”. How do i make sure “ls -ltr” is run after “ls -h” is suc

help me (2 Replies)
Discussion started by: sonu pandey
2 Replies

3. UNIX for Advanced & Expert Users

ls -ltr a list of filenames-with-spaces within a text file

OS: RHEL 5.8 shell: bash 3.2.25 Directory /home/guest/ contains these files: file a file b file c fileD fileE fileF testFile.txt I'm trying to find the syntax to run ls -ltr against this list of files that is contained within a text file, testFile.txt. The file testFile.txt has... (4 Replies)
Discussion started by: uschaafm
4 Replies

4. UNIX for Dummies Questions & Answers

ls -ltr for a future date/time stamp file

Hi When i do ls -ltr <file1> then it shows me the date and time of the file if - for whatever reason file has future date/time stamp then ls -ltr is not showing the time, it just shows only date part ... even if time is ahead by 2 hr than current time. suppose a file was copied from INDIA... (3 Replies)
Discussion started by: reldb
3 Replies

5. Solaris

using ls -ltr : display only last four file names

Hi , Server details – Machine hardware: sun4u OS version: 5.9 Processor type: sparc Hardware: SUNW,Sun-Fire-880 When I put ls –ltr command I get – /users/testuser> ls -ltr -rw-rw-r-- 1 testuser dba 76 Jan 13 2009 ftp.scr -rwxr-xr-x 1... (6 Replies)
Discussion started by: rahulbahulekar
6 Replies

6. Shell Programming and Scripting

Printing Year in ls -ltr command

Hi, When retrieving parameters of a file using ls command i need to print the year part . When i do ls -ltr the following output is displayed -rwxrwxrwx 1 d_infd d_infd 1711 Jan 8 2004 wf1.class. Here the year part is not displayed only Jan 8 is displayed. Can any one... (9 Replies)
Discussion started by: ragugct
9 Replies

7. Shell Programming and Scripting

ls -ltr command On Remote server

I am writing a script where in i have to log into a remote machine and check for necessary file by typing (ls -ltr *200505) (this gets all 05month of 2008 yr files) and if files are found get them to the local machine. If not found print a message saying no files on local machine. When i was... (2 Replies)
Discussion started by: vasuarjula
2 Replies

8. Programming

Help in extracting data with command from file in C

Hi, I have a file which stores the following array :- 1,2,3,4,5.........16,17,18,19,20 This file has few hundreds of inputs of these lines. I would like to read this file one line at a time; and assign to an array which is separated by ",". I tried to do fgets command however,... (10 Replies)
Discussion started by: ahjiefreak
10 Replies

9. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

10. UNIX for Dummies Questions & Answers

what does the ls -ltr command list

Hi, THe following is the output when i run the command ls -ltr can anyone explain the meaning of the field in red -rw-r----- 3 orca orca 20924 Sep 08 19:21 BTL027SASI.gnt -rw-r----- 3 orca orca 20924 Sep 08 19:21 BTL027RITD.gnt -rw-r----- 3 orca orca ... (2 Replies)
Discussion started by: ranjita.c
2 Replies
Login or Register to Ask a Question