The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-19-2009
techmoris techmoris is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 27
awk example

Hi,

In the following example,

ls -l *.pdf

-rw-r--r-- 1 devusr devgrp 4626001 Aug 11 13:50 0000783302.pdf
-rw-r--r-- 1 devusr devgrp 9675018 Aug 11 13:55 0000783683.pdf

I would like to retrieve the size, filename and filename without extension to a text file.

Desired Output:-

4626001,0000783302.pdf,0000783302
9675018,0000783683.pdf,0000783683

I have tried using the following command and it worked partially...
ls -l *.pdf | awk '{print $5","$9","$9}' > filename.txt

can someone advice on the above example to meet the desired output..

Thanks
  #2 (permalink)  
Old 08-20-2009
dr.house dr.house is offline
Registered User
  
 

Join Date: Dec 2008
Location: Switzerland
Posts: 229

Code:
[house@discovery] ls -l *.pdf | awk '{ print $5","$9","$9 }' | sed 's/\.pdf$//'
4626001,0000783302.pdf,0000783302
9675018,0000783683.pdf,0000783683

Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0