|
Prev: parsing-bash shell-awk
Next: backgrounded ssh tunnel waits for tunnel to close before exiting when using tee...?
From: rickm on 7 Apr 2008 15:16 I have a file that looks like this: poly poly metal1 metal1 metal2 metal2 metal3 metal3 but need to be able to change one column to uppercase so either: POLY poly
From: Johann Kappacher on 7 Apr 2008 16:53 rickm(a)galaxy.nsc.com wrote: > I have a file that looks like this: > > poly poly > metal1 metal1 > metal2 metal2 > metal3 metal3 > > but need to be able to change one column to uppercase so either: > > POLY poly > I would try: typeset -u UC while read UC LC do echo "$UC \t $LC" done < input_file
From: Johann Kappacher on 7 Apr 2008 16:56 Johann Kappacher wrote: > rickm(a)galaxy.nsc.com wrote: >> I have a file that looks like this: >> >> poly poly >> metal1 metal1 >> metal2 metal2 >> metal3 metal3 >> >> but need to be able to change one column to uppercase so either: >> >> POLY poly >> > I would try: > > typeset -u UC > > while read UC LC > do > echo "$UC \t $LC" > done < input_file > Perhaps, you will need to change the IFS (Input Field Separator) first. Please, check man page or tutorial for bash or ksh.
From: Ed Morton on 7 Apr 2008 17:27 On 4/7/2008 2:16 PM, rickm(a)galaxy.nsc.com wrote: > I have a file that looks like this: > > poly poly > metal1 metal1 > metal2 metal2 > metal3 metal3 > > but need to be able to change one column to uppercase so either: > > POLY poly > This may be what you want if you don't care about preserving the white-space: awk '{$1=toupper($1)}1' file If you do care, tell us what that white space is. Ed.
From: Johann Kappacher on 7 Apr 2008 17:33 Ed Morton wrote: > awk '{$1=toupper($1)}1' file Nice solution, not strict shell, but very nice! btw: what stands the 3rd "1" for? --jk
|
Next
|
Last
Pages: 1 2 3 Prev: parsing-bash shell-awk Next: backgrounded ssh tunnel waits for tunnel to close before exiting when using tee...? |