|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
cut words based on the word count of a line
I would like to cut words based on the word count of a line. This over here inspired me with some ideas but I wasn't able to get what I needed. http://www.unix.com/shell-programmin...ing-xargs.html If the line has 6 words I would like to use this. Code:
awk -F" " '{print $6}'If the line has 4 words I would like to use this. Code:
awk -F" " '{print $4}'I don't want to use a shellsript. I would like this to be just one line that I can put into my shell and it work. |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Code:
awk '{print $NF}' myFile |
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
I saw that from the link I gave. How do I cut the 4th word and 6th word based on word count.
|
|
#4
|
||||
|
||||
|
Quote:
Isn't that what your examples illustrate? When you say 'cut words' what do you example mean? Please provide a sample input a desired output. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
Quote:
sat thur |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Quote:
Does it not? |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Quote:
Quote:
sat thur |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Count and print all repeating words in a line | AshwaniSharma09 | Shell Programming and Scripting | 5 | 10-13-2010 07:24 AM |
| How to fetch rows based on line numbers or based on the beginning of a word? | Muthuraj K | Shell Programming and Scripting | 18 | 02-02-2010 04:27 AM |
| Count words on each line in file using xargs | Qwetek | Shell Programming and Scripting | 3 | 03-28-2009 06:21 PM |
| count no of words in a line | Satyak | Shell Programming and Scripting | 3 | 09-26-2008 11:52 AM |
| count no of words in a line | satish@123 | Shell Programming and Scripting | 7 | 05-21-2008 02:59 AM |
|
|