Updated: 8 October 2026 · Applies to: bash 5.2 on Debian 13 and bash 5.3 on Ubuntu 26.04 (identical output on both)
Ten wildcard one-liners for everyday file work on a server, each with the output it gave. Copy the one you need and change the names. Why each pattern works is explained in Linux wildcards and globbing; for patterns with find and safe use with rm, see using wildcards safely with find, ls, cp, mv and rm.
All examples ran in this folder:
$ ls IMG_0001.JPG access.log.3.gz error.log report10.txt IMG_0002.jpg backup-2026-09-28.tar.gz logo.png report2.txt access.log backup-2026-10-01.tar.gz nginx.conf site1 access.log.1 backup-2026-10-05.tar.gz photo.jpeg site2 access.log.2.gz backup-2026-10-07.tar.gz report1.txt site3
1. Rotated logs, but not the current one
$ ls access.log.* access.log.1 access.log.2.gz access.log.3.gz
2. Names with exactly one character in a position
$ ls report?.txt report1.txt report2.txt
report10.txt is left out because ? is always one character.
3. Backups from a range of dates
$ ls backup-2026-10-0[1-5]* backup-2026-10-01.tar.gz backup-2026-10-05.tar.gz
4. Several extensions at once
$ ls *.{jpeg,png}
logo.png photo.jpeg
If one of the extensions has no files, ls reports it, for example ls: cannot access '*.webp': No such file or directory.
5. Upper and lower case in one go
$ (shopt -s nocaseglob; ls *.jpg) IMG_0001.JPG IMG_0002.jpg
The brackets run it in a subshell, so case-insensitive matching does not stay on in your session.
6. Hidden files only
$ ls -d .[!.]* .env .htaccess
7. The same file in every site folder
$ grep DB_NAME */wp-config.php site1/wp-config.php:define( 'DB_NAME', 'shop_wp' ); site2/wp-config.php:define( 'DB_NAME', 'blog_wp' );
site3 has no wp-config.php, so it is skipped without an error.
8. Count the matching files
$ files=(backup-*.tar.gz); echo "${#files[@]}"
4
9. Rename every file with one extension
$ for f in *.jpeg; do mv -v -- "$f" "${f%.jpeg}.jpg"; done
renamed 'photo.jpeg' -> 'photo.jpg'
10. Preview, then delete old backups
$ echo rm -v backup-2026-09-* rm -v backup-2026-09-28.tar.gz $ rm -v backup-2026-09-* removed 'backup-2026-09-28.tar.gz'
Run the echo line first, check the list, then press the Up arrow and remove echo.
Linux file names are case-sensitive, so *.jpg on its own does not match IMG_0001.JPG; use example 5 when uploads come from phones or Windows PCs. To search below the current folder as well, use find with a quoted pattern, as shown in the find and wildcards guide. To check how much space the matched files use, see how to find the largest files and directories.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
