-2

From the 2 different web page the output goes to a single file called "traffic" From one page it always has a string "sqr" and from the other page it does not have the sqr string but "attach"

So:

read file traffic if it contains "sqr" then do the below 3 piece of code or if it contains "attach" do the below 4 piece of code

2
  • 2
    smells like homework
    – Creek
    Jun 20, 2014 at 11:35
  • 2
    You're not asking for help, you're asking us to write your script for you. What have you done? What have you tried? Post examples of your input and desired output (we can;t understand from your description) and also post what you have tried so far so we don't start from 0.
    – terdon
    Jun 20, 2014 at 11:36

1 Answer 1

2

You can use grep to determine whether a file contains a string or not. You can put the output of grep into a variable by using this syntax:

myvariable=$(grep string file)

Then use a conditional (if) to handle the results.

Example

$ if grep -q string file; then echo "found it"; fi

Not the answer you're looking for? Browse other questions tagged .