hi


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting hi
# 1  
Old 02-17-2005
hi

hi,

This is my first post....Hope u people will help me out
iam new to unix.

1)In a file i have something like this

fsdfsdf;
I need to find out totally how many semicolons are there. How do i find out

2) One another favour please. Iam going for a interview in another 2 days. I want to site which gives a good amount of faq's in unix and shells. Can some one suggest a site

Last edited by mkan; 02-21-2005 at 02:00 PM..
# 2  
Old 02-17-2005
one way:
Code:
tr ';' '\n' < file |wc -l
OR
sed -e 's/[^;]//g' file |wc -c

# 3  
Old 02-17-2005
And here is a site with a good amount of faq's in unix and shells. Smilie
# 4  
Old 02-18-2005
great thanku..
but for FAQ, u have given this site itself.
Please can you provide me with any other sites which will be useful for me for tommorw interview
# 5  
Old 02-18-2005
Looking on this site can give you a lot of good FAQ's, such as https://www.unix.com/answers-to-frequently-asked-questions/

You may wish to read this thread title
Read this if you are serious about being a Unix Admin...
# 6  
Old 02-21-2005
hi thanks locustfurnace

vgersh99 - sorry for asking this silly doubt

sed -e 's/[^;]//g' file |wc -c - this works fine no doubt,

but if i try

sed -e 's/;//g' file |wc -c - its not working why

i know ^ is used for excluding....what are u trying to do which makes it work
# 7  
Old 02-21-2005
Quote:
Originally Posted by mkan
hi thanks locustfurnace

vgersh99 - sorry for asking this silly doubt

sed -e 's/[^;]//g' file |wc -c - this works fine no doubt,

but if i try

sed -e 's/;//g' file |wc -c - its not working why

i know ^ is used for excluding....what are u trying to do which makes it work
sed -e 's/[^;]//g' file
replace all the characters that are not ';' with null-strings/nothing. This effectively removes any non-';' character.

What is left?

What is left are ';'-s - and we count [wc -c] them .
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question