Skip to main content
In English, the pronoun 'I' is capitalized; English contractions use apostrophes.
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 263

I am to find all files that start with certailcertain char , e.g

find . -maxdepth 1 \( -name "^m*" -a ! -name "g$" \) -print

but what if someone createcreated file that has special characters in the name of that file? for example

touch "
marst"

this wontwon't be found altoughtalthough it meets the crietrias , howcriteria. How should iI alter the code in order it to find even files whichs startswhich start with a space  ?

Also \( -name "^m*" -a ! -name "g$" \) will not work bcsbecause files in find are not "marr" but "./marr" which means this would find nothing , how. How to alter the code to match the start of the word too?

I am to find all files that start with certail char , e.g

find . -maxdepth 1 \( -name "^m*" -a ! -name "g$" \) -print

but what if someone create file that has special characters in the name of that file? for example

touch "
marst"

this wont be found altought it meets the crietrias , how should i alter the code in order it to find even files whichs starts with space  ?

Also \( -name "^m*" -a ! -name "g$" \) will not work bcs files in find are not "marr" but "./marr" which means this would find nothing , how to alter the code to match the start of the word too?

I am to find all files that start with certain char , e.g

find . -maxdepth 1 \( -name "^m*" -a ! -name "g$" \) -print

but what if someone created file that has special characters in the name of that file? for example

touch "
marst"

this won't be found although it meets the criteria. How should I alter the code in order it to find even files which start with a space?

Also \( -name "^m*" -a ! -name "g$" \) will not work because files in find are not "marr" but "./marr" which means this would find nothing. How to alter the code to match the start of the word too?

Source Link
trolkura
  • 417
  • 1
  • 6
  • 15

How to process special characters in in file name using find

I am to find all files that start with certail char , e.g

find . -maxdepth 1 \( -name "^m*" -a ! -name "g$" \) -print

but what if someone create file that has special characters in the name of that file? for example

touch "
marst"

this wont be found altought it meets the crietrias , how should i alter the code in order it to find even files whichs starts with space ?

Also \( -name "^m*" -a ! -name "g$" \) will not work bcs files in find are not "marr" but "./marr" which means this would find nothing , how to alter the code to match the start of the word too?