abacus
November 27, 2009, 5:45pm
1
Hello,
Please advise. Scoured this site, as well as google for answers. However if you do not know what to search for, it's a bit hard to find answers.
INPUT:
ACTASS=
802
BASECOS=
279
COSNCHG=
3
CUSCOS=
52
UPLDCOS=
2
DESIRED OUTPUT:
ACTASS=802
BASECOS=279
COSNCHG=3
CUSCOS=52
UPLDCOS=2
If solved can someone please direct in the correct route for a newbie scripter to find this answer. I am think search and then append bottom line to = sign.
Thank you to anyone that takes the time to explain. I have gained so much useful knowledge at this site.
Regards,
Abacus
danmero
November 27, 2009, 5:58pm
2
awk '{ORS=(/=/)?X:RS}1' file
abacus
November 27, 2009, 6:06pm
3
Holy Crap,
Amazing. I hate to ask you. However I have been studying awk and I will try to look this up. However can you please break this down.
I am thankful if you choose not too.
Thanks,
Abacus
PS: I am out of bits to award you. I will try however.
HEHE
SOLVED
danmero
November 27, 2009, 6:24pm
4
If you want to take the shortcut take a look at awk cheat sheet
What I did was just playing with ORS value, between RS and X(has no value, is NULL).
Success
while read -r line
do
case "$line" in
*=)
printf "%s" $line
read d
echo $d
;;
esac
done <"file"
danmero
November 27, 2009, 7:09pm
6
Another one:
while read -r line
do
case "$line" in
*=) printf "%s" $line;;
*) printf "%s\n" $line;;
esac
done < file
i think u can use only printf no fancy commands
printf %s%s"\n" $(cat filename)
Here's one way to do it with Perl:
$
$ cat f4
ACTASS=
802
BASECOS=
279
COSNCHG=
3
CUSCOS=
52
UPLDCOS=
2
$
$ perl -lne '/=$/ ? printf : print' f4
ACTASS=802
BASECOS=279
COSNCHG=3
CUSCOS=52
UPLDCOS=2
$
$
And a tad shorter:
perl -lnE '/=$/ ? printf : say' f4
Or:
perl -lne 'BEGIN{undef $/} s/=\n/=/g; print' f4
perl -lne '$.%2==1 ? printf : print' f4
tyler_durden
danmero
November 28, 2009, 12:13am
10
printf %s%s"\n" $(< file)
My bash can do that , no UUoC
And so can ksh and zsh, posix can't though.
xargs -n2 < urfile | tr -d ' '
abacus
November 28, 2009, 1:32pm
14
Thanks guys,
I now have to spend the rest of the weekend learning all your great code.
Thanks again to all who assisted.
Abacus