Operating System - HP-UX
1836636 Members
1839 Online
110102 Solutions
New Discussion

checking and replacing "/" (slash) with "-" (dash)

 
SOLVED
Go to solution
Pando
Regular Advisor

checking and replacing "/" (slash) with "-" (dash)

Dear Gurus,

I have a file which contains the line..
..
"12345/67"
..

I need a perl or other command to check if the value contains "/" then eventually replace the "/" with a dash "-" so that it would look like
..
"12345-67"
..

Maximum points for all correct replies.
Thanks!
4 REPLIES 4
Nguyen Anh Tien
Honored Contributor

Re: checking and replacing "/" (slash) with "-" (dash)

let do as:
#vi yourfile
:1,$s/\//-
then save and exit
HTH
tienna
HP is simple
Stuart Browne
Honored Contributor
Solution

Re: checking and replacing "/" (slash) with "-" (dash)

Somewhat ugly:

perl -pi -e 's/(>.*)\/(.*<)/\1-\2/' file_name
One long-haired git at your service...
Naveej.K.A
Honored Contributor

Re: checking and replacing "/" (slash) with "-" (dash)

Using sed

cat filename | sed 's/\//-/'

Regards,
Naveej
practice makes a man perfect!!!
Pando
Regular Advisor

Re: checking and replacing "/" (slash) with "-" (dash)

thanks for your replies!
It was a great help!