Modify the script, problem2.sh that does the following: 1. Creates a new variable (it does not have to be an environment variable) that is OUTFILE concatenated with ".out" 2. Prints out the value of this new variable (Hint: Use the echo command to print in bash.) 3. Creates a new variable that is OUTFILE concatenated with ".err" 4. Prints out the value of this new variable (Hint: Use the echo command to print in bash.) 5. Write a one line bash command that: 1. Runs cmd1 getting the input from INFILE 2. Pipes the output to cmd3 redirecting stdout (but not stderr!) to the filename you created in step 1, and stderr (but not stdout!) to the filename you created in step 3. When running with INFILE set to test

Respuesta :

Solution and Explanation:

problem2.sh

#!/usr/bin/env bash

# output file name for stdout

FILEOUT='test.out'

echo $FILEOUT

# output file name for stderr

FILEERR='test.err'

echo $FILEERR

# opening test.in and pipe to cmd1 and output of cmd1 pipe to cmd3 and giving file for stdout and stderr

cat test.in | ./cmd1 | ./cmd3 > $FILEOUT 2>$FILEERR

# END OF SCRIPT

# NOTE: it is to make sure all files in same directory including test.in

After running problem2.sh

$ ./problem2.sh

test.out

test.err

Otras preguntas