By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,271 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,271 IT Pros & Developers. It's quick & easy.

Need help with beginners unix script

P: 1
hi all,
can any one help with writting a unix script that knows to pull out from a file a string and retype it to a new file.
the string could appear in the file with a different value but its structure is the same (for example: "1A:CB:43:8D"), and the position of it in the line is always in the same place.
after the new file will be created, another function should go over it, and calculate and print the number of appearance of each string.

i will appreciate your help
Jul 19 '06 #1
Share this Question
Share on Google+
2 Replies

P: 168
Are you trying to get the forum to help with your college assignments?

Anyway, grep is the command you are looking for. Try to build a script around it. Following is an example...


grep ".{99}[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]" $fname | wc -w

will do what you asked for (assuming at 100th position in the file) without an intermediate file. (I have not tested this, but you can play with it until you get it right).

Suggest to get a good book on Regular Expressions or simply read man pages for grep, regex(7), perlre etc...
Feb 8 '07 #2

Expert 2.5K+
P: 3,237
sed would be a good choice as well.
Feb 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.