Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove first n character from bunch of file names with cut

Tags:

bash

cut

I am using

ls | cut -c 5-

This does return a list of the file names in the format i want them, but doesn't actually perform the action. Please advise.

like image 824
Ridalgo Avatar asked Feb 03 '15 17:02

Ridalgo


People also ask

How do I partially rename multiple files at once?

Select multiple files in a folder. To do so, press and hold down the CTRL key while you are clicking files. After you select the files, press F2. Type the new name, and then press ENTER.

How do you shorten multiple file names?

You can press and hold the Ctrl key and then click each file to rename. Or you can choose the first file, press and hold the Shift key, and then click the last file to select a group.

How do I trim file names?

Press CTRL + A to select all the files in the folder, then right-click and select Rename. Input your new file name, and press Enter. Each file in the folder will take the base file name, in this case, artwork, followed by a number in a sequence.


1 Answers

rename -n 's/.{5}(.*)/$1/' * 

The -n is for simulating; remove it to get the actual result.

like image 105
Aman Avatar answered Oct 09 '22 11:10

Aman