Avatar of nQuote
nQuote
Flag for Afghanistan

asked on 

Cutting and renaming files

I have some files such as:

abc.dat.xyz1234.001
abc.dat.xyz1234.002
abc.dat.xyz1234.003
and so on.

The files are pipe delimited as:
1|abc|hty|!
2|def|hju|!
and so on.

I would like to remove the first column value and the delimiter from all rows in the file. So the files need to look like this:
abc|hty|!
def|hju|!

I know I can do it using cut but I also need to rename the files as:
abc.dat.xyz1234.001 becomes abc.dat.00
abc.dat.xyz1234.002 becomes abc.dat.01
and so on.

Most important, the number of files is not fixed. The only difference between the file names is the last digit. Is there a simple way to do this?
Shell ScriptingLinuxUnix OS

Avatar of undefined
Last Comment
ozo

8/22/2022 - Mon