Re: Perl/or script command to grab from 3 char of filename to the end of filename ? (391 Views)
Reply
Super Advisor
Posts: 395
Registered: ‎10-20-1998
Message 1 of 3 (396 Views)

Perl/or script command to grab from 3 char of filename to the end of filename ?

got a list of filenames below

 

#ls

testing

trying

wonder

caprel

 

 cp the file above with new names as following (grab 3 character to the end of file) with the new filename  below after executing the command

 

sting

ying

nder

prel

 

good judgement comes from experience and experience comes from bad judgement.
Honored Contributor
Posts: 9,115
Registered: ‎02-23-2005
Message 2 of 3 (391 Views)

Re: Perl/or script command to grab from 3 char of filename to the end of filename ?

Acclaimed Contributor
Posts: 25,604
Registered: ‎03-06-2006
Message 3 of 3 (383 Views)

Re: Perl/or script command to grab from 3 char of filename to the end of filename?

Besides sed, you can also use shell parameter substitution:

fname=testing

echo ${fname#??}

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.