Results 1 to 6 of 6
Hi, I have a unix test for a job interview and 2 of the pre-test questions [for revision] I have been given, I don't quite understand!!! ...The questions are:
1. ...
- 08-31-2007 #1Just Joined!
- Join Date
- Nov 2005
- Location
- Bristol UK
- Posts
- 15
WHich command?
Hi, I have a unix test for a job interview and 2 of the pre-test questions [for revision] I have been given, I don't quite understand!!! ...The questions are:
1. Give a command to change all occurances of wordA to wordB for all files in a directory.
2. Give a command to count the number of lines matching a specified word in a file.
I thought I knew most of the basic UNIX commands, but have never ever come across such a situation when I would have to use either of these! ...Anyone have any ideas? thanks.
- 08-31-2007 #2
- 08-31-2007 #3Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
grep -c will count words found.
- 08-31-2007 #4
For replacing wordA to wordB
1. perl -p -i -e s/wordA/wordB/g `find .`---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------
- 08-31-2007 #5
Problem with that is it will require Perl to be installed
- 09-01-2007 #6Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
sed, or even awk, will do it nicely, check the man or info pages to see how to use them


Reply With Quote