Answers for "remove spaces from file names bash"

1

bash how to remove all whitespace from a file

# Example usage:
awk '{gsub(" ","",$0); print $0;}' input_file
# This replaces every space " " with nothing "", thereby eliminating all
# whitespace from the file

# Basic syntax:
awk '{gsub(regex, substitution_text, $field#); print $0;}' input_file
# Where:
#	- gsub is a function that replaces every regular expression (regex)
#		match with substitution_text. 
#	- $field# is optional but can be used to specify a particular field
#		where gsub should operate. (This is useful if you want to 
#		restrict the substitutions to a specific column)
Posted by: Guest on October-01-2020
0

remove spaces from file names bash

find . -name "* *" -type d | rename 's/ /_/g'    # do the directories first
find . -name "* *" -type f | rename 's/ /_/g'
Posted by: Guest on August-22-2021

Code answers related to "remove spaces from file names bash"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language