Results 1 to 5 of 5
Hi,
I need a scrip that could print the 5th, 10th, 15th... of any file
Any guess?...
- 07-28-2008 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 3
printing the nth word of anyfile
Hi,
I need a scrip that could print the 5th, 10th, 15th... of any file
Any guess?
- 07-28-2008 #2
What format is the file in? In other words, is there only one word on each line, or is it a series of words separated by spaces?
Registered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 07-28-2008 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 3
There are words separated by spaces in the file
- 07-28-2008 #4Obviously replacing file.txt with your file!Code:
awk '{print $2}' file.txt
Change the $2 to $10 to print the 10th word, etc.
This prints the 2nd and 4th words.Code:awk '{print $2 " " $4}' file.txtRegistered Linux user #388328 || Registered LFS user #15880
AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
Need instant help? Try us on IRC -- #linuxforums on freenode
- 07-29-2008 #5


Reply With Quote