6️⃣Wildcards

A wildcard is a character or a string of characters that can be used as a substitute for any other character(s) in a command-line expression.

  • * - zero or more characters

  • ? - single character

  • [] - range of characters

ls -l file*

this command prints all the files with expression file and anything after that. More clearly, it prints files starting with file and upto any characters after that.

ls -l [abc]123

can only have characters a,b and c and 123 after that

ls -l ?[123]

prints files with any first character and after that any number from 1-3

  • ^ - beginning of line

cat states.txt | grep ^A
  • $ - end of line

cat states.txt | grep sh$

Last updated