Hi all, I am trying to write a command that can help me count the number of lines in the /etc/passwd file ending in bash.
I have read through other threads but am yet to find one indicating how to locate a specifc word at the end of a line. I know i will need to use the wc command but when i attempt to combine this with grep it seems to do nothing at all. Below is the command i am entering:
cat /etc/passwd | wc | grep bash
If anyone can help me correct this and indicate where i am going wrong i'd be most grateful.
Thanks for that but i have one more question if within /etc/passwd i wanted to write a command to replace each instance of bin/bash from every line with bin/csh without manually editing the file how would i do that?
the back slashes are escape characters for the front slashes. The g reperesents 'global,' and will change every instance, not just the first occurance on each line.
$
$ cat f1
The first line.
This line has /bin/bash in it.
The third line.
This line has /bin/bash in it, twice => /bin/bash.
The fifth line.
And /bin/bash here and here /bin/bash and here /bin/bash
$
$ perl -pi.backup -e 's#/bin/bash#/bin/csh#g' f1
$
$ cat f1
The first line.
This line has /bin/csh in it.
The third line.
This line has /bin/csh in it, twice => /bin/csh.
The fifth line.
And /bin/csh here and here /bin/csh and here /bin/csh
$
$ cat f1.backup
The first line.
This line has /bin/bash in it.
The third line.
This line has /bin/bash in it, twice => /bin/bash.
The fifth line.
And /bin/bash here and here /bin/bash and here /bin/bash
$
$