LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-31-2007, 08:38 AM   #1
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Lubuntu 14.04 LTS, Kali
Posts: 297

Rep: Reputation: 30
Streamlining this awk construct


I'm trying to capture the 9th field of all but the first 2 lines of the ls command :

Code:
ls | awk ' NR > 2' | awk ' {print $9}'
Is there a way of streamlining this code so I only use one awk command as opposed to two. I've tried to use the for control statement but have failed !

Cheers,
Uncle
 
Old 10-31-2007, 09:20 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
with ls only , you won't be able to get field 9. use ls -l
Code:
ls -l | awk 'NR>2{print $9}'
 
Old 10-31-2007, 09:39 AM   #3
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Lubuntu 14.04 LTS, Kali
Posts: 297

Original Poster
Rep: Reputation: 30
Thanks a lot gd ! I've set an alias for ls to equal ls -al.

Cheers,
Uncle
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Construct a Service amirsarb Programming 2 06-01-2007 10:58 AM
Streamlining Feisty for best audio? Patrick K Ubuntu 4 05-17-2007 12:49 AM
Regex Explanation and streamlining craig467 Programming 4 03-22-2007 01:32 PM
Streamlining my notebook pkozub Linux - Laptop and Netbook 5 03-28-2006 04:09 PM
Streamlining my notebook pkozub Linux - Laptop and Netbook 1 03-26-2006 06:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration