To find all files in a directory with white space characters in the file names using the Bash shell, you can use the find
command with the -name
option.
For example, to find all files in the current directory with white space characters in the file names, you can use the following command:
find . -name "* *"Source:.wwwlautturi.com
This will search the current directory (.
) for files whose names contain a white space character. The * *
pattern will match any file names that contain a white space character.
You can use the -print
option to display the names of the matching files:
find . -name "* *" -print
You can also use the -exec
option to execute a command on the matching files. For example, to rename all the matching files by replacing the white space characters with underscores, you can use the following command:
find . -name "* *" -exec bash -c 'mv "$1" "${1// /_}"' -- {} \;
This will execute the mv
command on each matching file, replacing the white space characters in the file names with underscores.
It is important to note that the find
command is case-sensitive, so you may need to adjust the pattern to match the specific type of white space characters you want to find.