Perl/or script command to grab from 3 char of filename to the end of filename ? (315 Views)
Reply
Super Advisor
Sammy_2
Posts: 395
Registered: ‎10-20-1998
Message 1 of 3 (315 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.
Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,068
Registered: ‎02-23-2005
Message 2 of 3 (310 Views)

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

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,786
Registered: ‎03-06-2006
Message 3 of 3 (302 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#??}

Please use plain text.
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