LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 07:38 AM   #1
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Ubuntu 16.04.7 LTS, Kali, MX Linux with i3WM
Posts: 299

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, 08: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, 08:39 AM   #3
uncle-c
Member
 
Registered: Oct 2006
Location: The Ether
Distribution: Ubuntu 16.04.7 LTS, Kali, MX Linux with i3WM
Posts: 299

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

Cheers,
Uncle
 
  


Reply



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 09:58 AM
Streamlining Feisty for best audio? Patrick K Ubuntu 4 05-16-2007 11:49 PM
Regex Explanation and streamlining craig467 Programming 4 03-22-2007 12:32 PM
Streamlining my notebook pkozub Linux - Laptop and Netbook 5 03-28-2006 03:09 PM
Streamlining my notebook pkozub Linux - Laptop and Netbook 1 03-26-2006 05:16 PM

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

All times are GMT -5. The time now is 08:35 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