Re: removing name in pathname (163 Views)
Reply
Super Advisor
Henry Chua
Posts: 444
Registered: ‎09-05-2004
Message 1 of 8 (163 Views)
Accepted Solution

removing name in pathname

Hi Guys

If i have this"
D/DIR1/DIR2/DIR3
D/DIR4/DIR5/DIR6
"

in a log file.. how can I removed the D to make it
"
/DIR1/DIR2/DIR3
/DIR4/DIR5/DIR6"

Best regards
Henry


Please use plain text.
Regular Advisor
Isralyn Manalac_1
Posts: 114
Registered: ‎01-22-2004
Message 2 of 8 (163 Views)

Re: removing name in pathname

Hi Henry,

Use vi, then execute:

:%s/D\//\//g

regards,

Isralyn
Please use plain text.
Super Advisor
Henry Chua
Posts: 444
Registered: ‎09-05-2004
Message 3 of 8 (163 Views)

Re: removing name in pathname

Hi Isralyn,

I dun quite understand.. what do I have to do..if my log file is named "list".. then what should i do?

regards
Henry
Please use plain text.
Trusted Contributor
Amit Agarwal_1
Posts: 153
Registered: ‎06-02-2004
Message 4 of 8 (163 Views)

Re: removing name in pathname

You can use the sed command.

sed 's/D\//\//g'

Please note the backslash '\' is used to escape the forward slash '/'.

Please use plain text.
Honored Contributor
Muthukumar_5
Posts: 4,030
Registered: ‎06-09-2004
Message 5 of 8 (163 Views)

Re: removing name in pathname

You can do as,

sed -i 's/^D//' list

It will remove D in the begin and update it in to list file also.

HTH.
Easy to suggest when don't know about the problem!
Please use plain text.
Regular Advisor
Isralyn Manalac_1
Posts: 114
Registered: ‎01-22-2004
Message 6 of 8 (163 Views)

Re: removing name in pathname

Hi Henry,

My apologies but upon looking back into the displayed output of the one I posted, it looks confusing. I'll attach it as a word doc. What I suggested is using global string replacement in vi.

Regards,

Isralyn
Please use plain text.
Honored Contributor
Biswajit Tripathy
Posts: 508
Registered: ‎12-11-2004
Message 7 of 8 (163 Views)

Re: removing name in pathname

D/DIR1/DIR2/DIR3
D/DIR4/DIR5/DIR6

Correct me if I understand your question
incorrectly. My understanding is, you want to
remove all the chars from the beginning of the line
till the first '/' char. If that's what you want, the
following script should do it:

---
while read -r line
do
echo ${line#*/}
done < /your/logfile
--

- Biswajit
:-)
Please use plain text.
Super Advisor
Henry Chua
Posts: 444
Registered: ‎09-05-2004
Message 8 of 8 (163 Views)

Re: removing name in pathname

Thanks guys found the answer I wanted..
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