The script is supposed to take at least two arguments. I fixed all the initial error messages for this already. Then it is supposed to concatenate the contents of all the files(X2 . . . Xm) but the first file and copy this to standard out and print errors to the first file (X1). I know I need a loop to concatenate all the contents, but how do I set up the loop using the shift function to move through the arguments while keeping the first argument x1 to do the error stuff?
Linux shell script question about loops?
The best way to do this (in bash) is to save the first filename (X1) into a variable, shift if off of the $@ list, then loop through the remaining files using "for". Here's a rough outline of how the script might look, you'll just have to add the cat'ing and error redirection.
# save the name of the first file
ERRORFILE="$1"
echo The error file is $ERRORFILE
# remove the first file from $@
shift
# loop through the remaining files in
echo The remaining files are:
for FILENAME in $@ ; do
echo $FILENAME
done
tanning
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment