0

I am trying to write a script for Linux on tcsh. I have not written a script since maybe 98 on Unix and that was very basic stuff.

I am trying to take a string and find sub strings in it. For example in a very long string that is a devices status I'd like to find a sub sting "the status: " and if said sub string is found read the next word(string) following that sub string.

Basically I have a variable called INFO that is populated after sending out a command and I want to search it. I can of course loop through the whole thing but I know there are shorter ways of doing so, I just can't remember how anymore.

Plus if anyone knows of a decent source for script writing info that would be of use to me.

Hope this makes sense. PS If it were my choice I'd write this in straight up code and be done yesterday, but not my decision.

Thanks.

Thor
  • 45,082
  • 11
  • 119
  • 130
Dixon Steel
  • 1,021
  • 4
  • 12
  • 27
  • You're likely to get a lot more help with bash than tcsh, which is legacy software no longer shipped with any Linux distros by default. Have you tried simply googling "shell script tutorial"? I see lots of results that look promising. – Andy Ross Jul 12 '12 at 19:27
  • Thanks, now that I have figured out what words to use I have found some pattern matching stuff, which has been successful using awk. I just need to figure out, once I find a match how to get the next word following the match. – Dixon Steel Jul 12 '12 at 19:56

1 Answers1

0

Here's a good tutorial source, it has several sections: http://www.dreamsyssoft.com/unix-shell-scripting/tutorial.php

Rocky Pulley
  • 22,531
  • 20
  • 68
  • 106