ric79
1
Hi all,
I need a simple bin/sh script
FILE1:
ab1 gegege swgdeyedg
ac2 jxjjxjxjxxjxjx
ad3
ae4 xjxjxj zhzhzh ahahs
af5 sjsjsjs ssjsjsjsj sjsjsj
ag6 shshshshs sjjssj
shhshshs
myScript.sh has to return:
ROW ab1
ROW ac2
ROW ad3
ROW ae4
In other words: "ROW " + the first world of the first 4 lines
Thanks
RIccardo
If you need only a solution for your problem:
awk 'NR<5{print "ROW" FS $1}' file
If this is a homework and you are limited to sh please post your problem on Homework & Coursework Questions - The UNIX and Linux Forums
#!/usr/bin/bash
for file in `cat "file.txt" | grep -v "shhshshs" | awk '{print $1}'`
do
echo ROW $file
done
leo@lein:~/Escritorio$ cat file.txt
ab1 gegege swgdeyedg
ac2 jxjjxjxjxxjxjx
ad3
ae4 xjxjxj zhzhzh ahahs
af5 sjsjsjs ssjsjsjsj sjsjsj
ag6 shshshshs sjjssj
shhshshs
leo@lein:~/Escritorio$ bash shell.sh
ROW ab1
ROW ac2
ROW ad3
ROW ae4
ROW af5
ROW ag6
leo@lein:~/Escritorio$