Re: Perl/or script command to grab from 3 char of filename to the end of filename ? (375 Views)
Reply
Super Advisor
Sammy_2
Posts: 395
Registered: ‎10-20-1998
Message 1 of 3 (380 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
Steven Schweda
Posts: 9,091
Registered: ‎02-23-2005
Message 2 of 3 (375 Views)

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

Acclaimed Contributor
Dennis Handly
Posts: 25,190
Registered: ‎03-06-2006
Message 3 of 3 (367 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.