Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I remove whitespace characters within file names?

0
Posted

How can I remove whitespace characters within file names?

0

File names in unix can contain all kinds of whitespace characters, not just spaces. The following examples only work with spaces, adjust accordingly. a. Use the substitution capabilities of awk, sed, et al. f=`printf ‘%s\n’ “$filename” | sed ‘s/ /_/g’` f=`printf ‘%s\n’ “$filename” | awk ‘{gsub(” “,”_”);print $0}’` f=`printf ‘%s\n’ “$filename” | tr ‘ ‘ _` Add characters to the tr command line as needed (see the man page for tr to find out the available escape sequences). Additionally (although not exactly a one-liner) f=`tr ‘ ‘ _ <

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123