Ubuntu 18.04 – shell and wildcards

Wildcards are special characters that represent other characters., <span>Ubuntu 18.04 – shell and wildcards</span>, KandZ

Wildcards (* , ?, []) are special characters that represent other characters. You can use them with any command.

  • * – matches all the characters or files in a directory
  • ? – matches only one character
  • [] – matches any character from inside the brackets []

Examples

cp f* Downloads

It copies all the files that starts with f to the subdirectory Downloads

Wildcards are special characters that represent other characters., <span>Ubuntu 18.04 – shell and wildcards</span>, KandZ
cp * Downloads

It copies all the files to the subdirectory Downloads

rm *

Deletes all the files in the directory

Wildcards are special characters that represent other characters., <span>Ubuntu 18.04 – shell and wildcards</span>, KandZ

cp fi*.txt Downloads

It copies all the files starting with fi and have an extension txt to the subdirectory Downloads

Wildcards are special characters that represent other characters., <span>Ubuntu 18.04 – shell and wildcards</span>, KandZ
cp file?.txt Downloads

It copies all the files that start with file, it has one more character (it can be whatever character) and with extension txt

Wildcards are special characters that represent other characters., <span>Ubuntu 18.04 – shell and wildcards</span>, KandZ
ls [dD]*

It shows all the files/directories that start with d or D

Wildcards are special characters that represent other characters., <span>Ubuntu 18.04 – shell and wildcards</span>, KandZ
64090cookie-checkUbuntu 18.04 – shell and wildcardsUbuntu 18.04 – shell and wildcards

Related posts

4 Thoughts to “Ubuntu 18.04 – shell and wildcards

Comments are closed.