Help!:simple shell script

Help!:simple shell script

Post by Yong-Rim Rh » Tue, 07 Feb 1995 09:26:02

if (grep 'a string' .temporary) then do this an that

So basically, how would I use the 'grep' command as the condition of the 'if' command?  Does the grep command return any



Help!:simple shell script

Post by PJGent » Sat, 11 Feb 1995 11:25:33

If your on System V version of UNIX grep returns 1 of 3 possible error
codes.  If any matches where found, grep will return 0.  If no matches
were found, then grep returns 1.  Finally, 2 is returned if there was a
syntax error in the grep command string.

Good Luck!


1. Shell Script Help (C-Shell Script)

In my class we had to write a C program and now we have to write a shell
script to do the exact same thing. I am not sure where to get started using
tr and sed to accomplish this assignment. Here is the assignmnet...

(1) remove all non-printing characters (character codes 1 through 31,
   and 127) and replace them with the same sort of codes the vi
   editor uses.  For example, the bell character (character code 7)
   is replaced by the two printable characters "^" and "G" (G is the seventh
   letter of the alphabet).  Appendix I of Foster lists the ASCII character
   set, and it shows all the proper two-character sequences that should
   be used for the non-printing characters.  There are two special cases:
   Replace the delete character by "^?".  Newlines should be replaced by a
   dollar sign ("$") and then an actual newline.
   **you may ignore NUL (character code 0)**

(2) delete all non-ASCII characters (those with character codes 128 through

(3) truncate all output lines that would otherwise extend past column 72.
   reading the data on the next line after ignoring the rest of the
character past column 72.

Make sure it reads from stdin and prints to stdout.  It should be comprised
of standard UNIX utilities (that is, it should not invoke any specialized C
that you may consider writing). You MUST make use of pipes rather than using
files to store intermediate results.  Don't make this assignment
unnecessarily hard: the whole program can be done in ONE line (not counting
all the documentation lines).

I was thinking that (1) could be accomplished by using a tr line like ( tr
'\001-\011' '\136') but that replaces some of the non printing with the ^,
how would i get the letter in there and would I have to have a bunch of
those tr commands piped together just to accomplish (1)?

Some help on this would really really be appreciated as its due on Monday
and I've hit a brick wall on this one.


2. Netscape News Posting

3. help-simple c shell script

4. fvwm error!!

5. Help with simple shell script please

6. How to print in C program?

7. Simple Shell Script Help

8. csh: too many values in environment

9. Help in converting simple shell script.

10. Error in a (very simple) shell script - help...

11. simple shell script-pls help

12. Help! Simple Shell Script Loop using multi-files

13. Help with simple shell script.