Article 5E13N remove newline and tab characters from filename

remove newline and tab characters from filename

by
oliveoyl
from LinuxQuestions.org on (#5E13N)
Hello,

I've got some files that have \n and \t characters in the filenames that I'd like to remove.

This works great for the first newline:

rename $'\n' '' FILE*

I can run this again to remove the next new line but is it possible to capture multiple newlines with one command?

How to remove tabs? How to remove both at once?

# ls -lb
T1\tThisFileNameHas\tTabs
N1\nThisFileNameHas\nNewlines
TN1\tThis\nFileName\nHas\tTabsandNewlineslatest?d=yIl2AUoC8zA latest?i=iBxsSfnfDNE:r9m7fmdWmo4:F7zBnMy latest?i=iBxsSfnfDNE:r9m7fmdWmo4:V_sGLiP latest?d=qj6IDK7rITs latest?i=iBxsSfnfDNE:r9m7fmdWmo4:gIN9vFwiBxsSfnfDNE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments