Text FIle
[adimulamvenkat19851609@cxln4 ~]$ cat two.txt
-32 45 65 -89 -100 65 -54 78 -56
56 85 -645 89 -56 -57 33 55
23 26
25 -56
123 654 -56 -56 89 -100 200
600 -77 -1000 59 -666
-32 45 65 -89 -100 65 -54 78 -56
56 85 -645 89 -56 -57 33 55
23 26
25 -56
123 654 -56 -56 89 -100 200
600 -77 -1000 59 -666
#with Command
[adimulamvenkat19851609@cxln4 ~]$ cat two.txt | awk 'NR==5 {$1*= -1; $2*= -1; $3*= -1;$4*= -1;$5*= -1;$6*= -1;$7*= -1;$8*= -1;$3*= -9;print}'
-123 -654 -504 56 -89 100 -200 0
=====================================================================
#With Bash Script
#!/bin/bashecho "enter a filename to print from awk"
read fileName
echo "enter a row number for print"
read row_num
i=0
while read line;
do
i=$(( i + 1 ))
case $i in $row_num)
echo "Before Convert"
echo "$line"
echo "==========================="
echo "Before Convert"
echo "$line" | awk ' {$1*= -1; $2*= -1; $3*= -1;$4*= -1;$5*= -1;$6*= -1;$7*= -1;$8*= -1;$3*= -9;print} '
break;; esac
done <"$fileName"
[adimulamvenkat19851609@cxln4 ~]$ sh hello.sh
enter a filename to print from awk
two.txt
enter a row number for print
5
Before Convert
123 654 -56 -56 89 -100 200
===========================
Before Convert
-123 -654 -504 56 -89 100 -200 0