[adimulamvenkat19851609@cxln4 ~]$ cat>one.txt
10 -20
-30 40
-50 60
-60
80 -90
100 -200
#With Commands
[adimulamvenkat19851609@cxln4 ~]$ awk ' NF { $1 *= -1 } 1 ' one.txt | awk ' { print $1 } '
-10
30
50
60
-80
-100
[adimulamvenkat19851609@cxln4 ~]$ awk ' NF { $2 *= -1 } 1 ' one.txt | awk ' { print $2 } '
20
-40
-60
0
90
200
#With Script
#! bin/bash
#converting columns values to row values
echo "enter a filename to print from awk"
read fileName
if [[ -f $fileName ]]
then
echo " before convert 1st column"
cat $fileName | awk ' { print $1 } '
sleep 3
echo "============================================================"
echo " After convert 1st column into 1st row"
cat $fileName | awk '{ printf( "%s ", $1 ); } END { printf( "\n" ); }'
else
echo "$fileName doesn't exist"
fi
[adimulamvenkat19851609@cxln4 ~]$ sh hello.sh
enter a filename to print from awk
one.txt
before convert 1st column
10
-30
-50
-60
80
100
============================================================
After convert 1st column into 1st row
10 -30 -50 -60 80 100