bash

Escaping characters on the command line by Joseph Palumbo

While doing some housekeeping on my computer I ran into a situation where I wanted to delete all files that had a (1) in the name.

I started by listing all files that ended in .jpg

$ ls *.jpg
Screenshot 2019-10-07 13.50.50.jpg

I thought I could delete those files using basically the same syntax on the command line, but this is what I got when I tested it out.

Screenshot 2019-10-07 13.53.37.jpg

After Googling around I found this article on apple.stackexchange.com that helped me figure it out.

You can use the \ to escape characters on the command line, like this:

$ ls *\(1\).jpg
Screenshot 2019-10-07 13.56.02.jpg

Which lead to this solution:

Screenshot 2019-10-07 13.58.09.jpg