1752815 Members
5847 Online
108789 Solutions
New Discussion юеВ

Re: Rename file

 
SOLVED
Go to solution
ankitj1983
Frequent Advisor

Rename file

Hello All,

When i am ruuning the below command on command prompt its running fine.

paste pol_dsk disk_eux290|sed -e 's/ / to /g' -e 's/^/change /g'>rname.txt

But when running the same command in shell script rename.txt is not building.

Desired output

###########
change /dev/rdsk/c170t6d2 to /dev/rdsk/c66t7d6
change /dev/rdsk/c170t7d7 to /dev/rdsk/c66t7d7
###########

Getting the output while putiing in script.

#########

/dev/rdsk/c170t14d2 /dev/rdsk/c66t10d1
/dev/rdsk/c171t2d6 /dev/rdsk/c66t10d2
/dev/rdsk/c171t4d2 /dev/rdsk/c66t10d3
##########

To is getting missing & i thik there is TAB issue.

Regards

Ankit
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: Rename file

Hi:

Posting an attachment with your actual input would be more helpful than having us assume that it looks like.

Since you mention 'paste', you might want to specify the delimiter with '-d" "' which would declare it as a space and not a tab character.

The 'sed' command you show *appears* to try to match a space but that can't be ascertained from the way the Forum displays things. Since HP-UX 'sed' doesn't support the specification of the TAB characters with '\t' in 'sed' expressions, you might write:

# paste pol_dsk disk_eux290|sed -e 's/[ \t] / to /' -e 's/^/change /' > rname.txt

...where '\t' is actually replaced with the TAB character typed from the keyboard.

You might also do:

# paste -d" " pol_dsk disk_eux290|sed -e 's/ / to /' -e 's/^/change /' >rname.txt

...which is to say, specify the 'paste' delimiter.

In both cases, based on your input/output, the 'g'lobal replacement is superfluous.

Regards!

...JRF...

ankitj1983
Frequent Advisor

Re: Rename file

Hi James

its worked for me.

Thanks for your solution.

Regards

Ankit

ankitj1983
Frequent Advisor

Re: Rename file

Closing the thread.