What I'm attempting to do:
- Line 1: find any .txt or .TXT file and pipe them into next command
- Line 2: convert the .txt file to unix format (get rid of Windows line endings)
- Line 3: delete the last line of the file, which is always blank
find "${TEMPDIR}" -name *.[Tt][Xx][Tt] | /
xargs dos2unix -k | /
dd if=/dev/null of="$_" bs=1 seek=$(echo $(stat --format=%s "$_" ) - $( tail -n1 "$_" | wc -c) | bc )
I can't pipe the (EDIT output) filename of xargs dos2unix -k | /
into the third line, I get the following error:
stat: cannot stat '': No such file or directory
tail: cannot open '' for reading: No such file or directory
dd: failed to open '': No such file or directory
Clearly Iv'e wrongly assumed that "$_"
will be enough to pass the output through the pipe.
How can I pipe the output (a text file) from xargs dos2unix -k
into the third line, dd if=/dev/null of="$_" bs=1 seek=$(echo $(stat --format=%s "$_" ) - $( tail -n1 "$_" | wc -c) | bc )
?
The solution for line 3 comes from an answer to another question on SO about removing the last line from a file, with this answer in particular being touted as a good solution for large files: https://stackoverflow.com/a/17794626/893766
Can this help?