I have the following shell script and they ask me to know how works and what the $1 and $2 parameters are.
#!/bin/bash
for i in `sort $1`; do
if grep $2 $i > /dev/null; then
echo A
cp $i /tmp
exit
fi
done
echo B;
My question is this: $1 can not be a directory because you can not sort on directories. Therefore, it must be a file. But the "for i in file" function implies that we will work for each line and the 'grep' tool does not work with lines.
I have considered that it should be a file that contains files, but for now I can only think of the tar files and it does not work with them.
Thanks!
*as a line in your file, it'll be replaced with a list of everything in your current working directory).