![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| change 43% to 43.5 | nortypig | Shell Programming and Scripting | 2 | 08-20-2006 12:55 AM |
| IP change | kuultak | UNIX for Dummies Questions & Answers | 2 | 07-13-2005 06:01 AM |
| UID Change | mcateriny | AIX | 4 | 10-06-2003 09:02 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
change wc -l
Hi,
I would like realize a script that it can change " wc -l" with "wc -l | sed 's/ //g'", but my problem is that i can have a pipe ,a variable ( many variable different) or a file after wc -l ?how i could test this several case ? wc -l | cut -d' ' -f1` if [ `wc -l <$FILE` -ne 1 ] wc -l ${F} | awk '{print $1 }' Thank you for your help. |
| Forum Sponsor | ||
|
|
|
|||
|
I believe the function I posted earlier should work for all these cases.
Pb with space wc -l Because I don't have the space problem, I made a slightly different wc function for testing here. Code:
vnix$ type -all wc
wc is /usr/bin/wc
vnix$ wc () {
> set -- `/usr/bin/wc "$@"`
> echo $1
> }
vnix$ wc /etc/motd
8
vnix$ wc -l /etc/motd
8
vnix$ /usr/bin/wc /etc/motd
8 50 338 /etc/motd
vnix$ wc -l </etc/motd | cut -d ' ' -f1
8
vnix$ if [ `wc -l </etc/motd` -eq 8 ] ; then echo foo ; fi
foo
vnix$ F=/etc/motd
vnix$ wc -l $F | awk '{ print $1 }'
8
|
|||
| Google UNIX.COM |