Reputation: 111
I want to read with whitespaces and special characters because I need to delete file with the name of that string. I don't know how to deal with "\" and last spaces in read; I am probably doing it wrong.
while read LINE
do
for arg in $LINE
do
if [ "${args}" = "" ]
then
args="${args}"
else
args="${args}' '"
fi
args="${args}${arg}"
done
I need to do something like that echo sadsad asddsa ;' dsasa | ./sth.sh | xargs -l rm -f
I think that I need to set IFS to "|" but it doesn't work properly. I need to read input end call it.
EDIT: Ok, I think I only need to do something with xargs and sed.
Ok, almost thant I have some errors but I get file name
find *.txt -print0 | xargs -0 rm -f
This works fine for me :). Problem probably solved.
Upvotes: 0
Views: 1917
Reputation: 43688
Try:
while read -r line
do
echo rm -- "$line"
done
-r
means that backslash don't get special treatment.
Upvotes: 2