![Quote](images/ubuntu-VB4/misc/quote_icon.png)
Originally Posted by
steeldriver
Code:
for file in *.md5; do sed '$s/\r$//' "$file"; done
sed -s '$s/\r$//' *.md5
The loop is probably safer if there are MANY (thousands of) files because of limits on max argument length.
Wow ... I'm impressed! Both methods work perfectly!
And you were right ... the first syntax only deals with the 'last line of input'.
But what do you mean with "... of limits on max argument length"?
Many thanks so far!
Next question. I'd like to ass the result to md5sum. This doesn't work. I don't understand the error message.
Code:
root@ganymede:~# for file in *.md5; do sed '$s/\r$//' "$file"; done -exec md5sum -c {} \;
-bash: syntax error near unexpected token `-exec'
Using an intermediate file works.
Code:
root@ganymede:~# for file in *.md5; do sed '$s/\r$//' "$file"; done > md5.md5
root@ganymede:~# md5sum -c md5.md5
...
... later ...
This works!
Code:
root@ganymede:~# for file in *.md5; do sed '$s/\r$//' "$file"; done | md5sum -c
...
Thanks for the help!
Bookmarks