Remove newlines in file names
Using the utility rename
from util-linux, which CentOS 6 provides, and assuming bash:
rename $'\n' '' wget_*
This asks to delete newline characters from the names of listed files. I recommend trying it out on a small subset to ensure it does what you want it to (note that rename
on CentOS 7 supports a -v
switch to show you what changes it is making).
If instead you were on a distribution that provides the Perl-based rename
:
rename -n 's/\n//g' wget_*
And then run without -n
to actually perform the renaming.
Building on what was already answered, I've generalized it to rename all files containing line feed in current folder and sub-folder, by combining find command with rename -
find -name $'*\n*' -exec rename $'s|\n| |g' '{}' \;
Here, find command locates all files containing line feed and rename command replaces every line feed in the name with a space.
The same can be done for any other such problematic characters such as carriage return (\r).