Operating System - HP-UX
1748041 Members
5376 Online
108757 Solutions
New Discussion юеВ

Re: removing name in pathname

 
SOLVED
Go to solution
Henry Chua
Super Advisor

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


7 REPLIES 7
Isralyn Manalac_1
Regular Advisor
Solution

Re: removing name in pathname

Hi Henry,

Use vi, then execute:

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

regards,

Isralyn
Henry Chua
Super Advisor

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
Amit Agarwal_1
Trusted Contributor

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 '/'.

Muthukumar_5
Honored Contributor

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!
Isralyn Manalac_1
Regular Advisor

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
Biswajit Tripathy
Honored Contributor

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
:-)
Henry Chua
Super Advisor

Re: removing name in pathname

Thanks guys found the answer I wanted..