Link to home
Start Free TrialLog in
Avatar of mnis2008
mnis2008

asked on

korn script help - AIX

I have a list of LUN ID's
002D8
007A6
01245
0079E
0008E
00796
0008D
0077B
002E0
00773
00969
0076B

How do I convert into an output like this
# command " 002D8 | 007A6 | 01245 | 0079E | 0008E | 00796 | 0008D | 0077B | 002E0 | 00773 | 00969 | 0076B"
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

awk '{if(NR==1) printf "#command \"%s | ", $0; else printf "%s | ", $0} END {print "\b\b\""} lunlist
cat <<! | tr "\n" "|" | sed -e "s/|/ | /g"
002D8
007A6
01245
0079E
0008E
00796
0008D
0077B
002E0
00773
00969
0076B
!
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mnis2008
mnis2008

ASKER

Hello WMP

Thanks for your help but I wanted to output with no spaces
# command " 002D8|007A6|01245|0079E|0008E|00796|0008D|0077B|002E0|00773| 00969|0076B"

I copied and pasted from a notepad and some how we got this spaces ...
No problem.

awk '{if(NR==1) printf "# command \"%s|", $0; else printf "%s|", $0} END {print "\b\""}' lunlist

I removed the space between the first quotation mark and the first LUN ID as well. Hope that's OK.
thanks, works now