Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

doubt in tr

4 posters

Go down

doubt in tr Empty doubt in tr

Post by soumya22 Fri Mar 05, 2010 4:38 pm

$ cat /etc/shells | sed 's/bash/BASH/g' | tr '[a-z]' '[A-Z]'

also i have a doubt to use head using sed...and wc -l using sed
thnx in advance.:-)

soumya22

Posts : 4
Points : 6
Join date : 2010-03-03

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by Christopher Fri Mar 05, 2010 4:43 pm

in above stmt, sed will replace all 'bash' to 'BASH' and tr converts all lowercase to uppercase.

I think this is not ur question. can u be little clear???
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by soumya22 Fri Mar 05, 2010 4:46 pm

actually it is showing error

tr: missing operand after `[a-z][A-Z]'
Two strings must be given when translating.
Try `tr --help' for more information.

soumya22

Posts : 4
Points : 6
Join date : 2010-03-03

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by soumya22 Fri Mar 05, 2010 4:48 pm

k....we solved it...



but how to use 'head' in sed 'wc -l' in sed

soumya22

Posts : 4
Points : 6
Join date : 2010-03-03

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by Christopher Fri Mar 05, 2010 4:51 pm

check the quotes.
it should be tr '[a-z]' '[A-Z]'. I guess u typed as tr '[a-z] [A-Z]'
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by Saradha Kannan Fri Mar 05, 2010 4:53 pm

i dont think the question is using head in sed.. its showing the fnality of head in sed..

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by Saradha Kannan Fri Mar 05, 2010 4:54 pm

$ sed 2q /etc/shells
/bin/sh
/bin/bash
This is same as head -2 /etc/shells

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by anand Fri Mar 05, 2010 4:55 pm

head:
sed '10q' aaa.txt
==>first ten lines ll be printed...
wc :
sed -n '$=' aaa.txt
===> willl print t count of lines
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by anand Fri Mar 05, 2010 4:56 pm

further reference for "sed " command check out "unix cmd doubt " topic in this forum....
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by Christopher Fri Mar 05, 2010 4:57 pm

To count number of characters in first 3 lines of the file.

Code:
$ sed '3q' <filename> | wc -c


Last edited by Christopher on Fri Mar 05, 2010 4:58 pm; edited 1 time in total
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by soumya22 Fri Mar 05, 2010 4:57 pm

thanks :-)

soumya22

Posts : 4
Points : 6
Join date : 2010-03-03

Back to top Go down

doubt in tr Empty Re: doubt in tr

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum