![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A question/problem about oracle "tns listener" and "enterprise manager" | talipk | UNIX and Linux Applications | 0 | 12-01-2008 03:08 PM |
| "|" separated file validations | kolesunil | Shell Programming and Scripting | 1 | 05-27-2008 06:19 AM |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Code:
> echo "word1 word2 word3" | cut -d" " -f2
word2
> echo "word1 word2 word3" | cut -d" " -f2
> echo "word1 word2 word3" | tr -s " " | cut -d" " -f2
word2
> echo "word1 word2 word3" | awk '{print $2}'
word2
The tr -s will suppress repeated consecutive characters; thus eliminating the extra space characters. Awk natively separates on space (one or more) or tab characters. |
|
|||||
|
Hey Joey, thanks so much! how do I write it (with tr) in my script? like this? Code:
set list = `tr -s " " | cut -d" " -f2 ${1}`
or like this: Code:
set list = `cat ${1} | tr -s " " | cut -d" " -f2`
or in a different way? And what is the tr function anyway? what does it do? |
|
|||||
|
Code:
> cat file146 val1 val2 val3 val4 val5 val6 val7 val8 val9 > tr -s " " <file146 | cut -d" " -f2 val2 val5 val8 > tr -s " " <file146 | cut -d" " -f2 >file146.out > cat file146.out val2 val5 val8 OR.... Code:
> mylist=`tr -s " " <file146 | cut -d" " -f2`
> echo ${mylist}
val2 val5 val8
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|