So I am having an issue with piping an ls
command to grep
. Im basically running ls -l
within a for loop on a file where some are missing, so it gives me the No file or directory found
error for three of the lines. What I can't figure out is how to parse only those lines and output it to another file/variable.
for i in $file
do
line=`/bin/echo $i | sed 's/source1_dir/dest1_dir/g'`
/bin/ls -l $line | grep -i "No file"
done
When I try to do that, it outputs the three errors but I am unable to pipe those errors to another file, if that makes sense. I think it's an issue with stderr but I'm not sure.