hi team
i have file test which contain
hi how are u
hi how u doing
hellooo
gud morning
excepted output is
hi how are
hi how u doing
hellooo
gudmorning
i want space between 2nd and 3rd row of the file
hi team
i have file test which contain
hi how are u
hi how u doing
hellooo
gud morning
excepted output is
hi how are
hi how u doing
hellooo
gudmorning
i want space between 2nd and 3rd row of the file
Try it in below format...
hi how are
hi how u doing
echo " \n "
hellooo
gudmorning
its just a sample if there are 1000 lines and i need space between ever lines .
is there any command to do this . . .like SED,AWK
---------- Post updated at 11:30 PM ---------- Previous update was at 02:13 AM ----------
hi team
let me explain clearly what i want
i have a file test contain some 9 lines
hi how u doing
hi helloo how r u
today is sunday
k we will go out
what u r doing here
shall we go to home
k we will meet later
i will call u tonite
take of ur pets
i want a line space between every three lines
my excepted output will be
hi how u doing
hi helloo how r u
today is sunday
k we will go out
what u r doing here
shall we go to home
k we will meet later
i will call u tonite
take of ur pets
#!/bin/bash
i=0
while read -r LINE
do
if [ "$i" -eq 3 ];then
echo ""
i=0
else
echo "$LINE"
((i++))
fi
done < "myfile"
thnks kurumi , but its shows some error
#!/bin/bash
i=0
while read -r LINE
do
if [ "$i" -eq 3 ];then
echo ""
i=0
else
echo "$LINE"
((i++))
fi
done < "test"
Error
-bash-3.00$ sh line.sh
line.sh: -r: is not an identifier
use bash
-bash-3.00$ bash line.sh
thnks kurumi its working , but some mischange . it delete the line after 3rd line and make it as a line space . .
input
-bash-3.00$ cat test
hi how u doing
hi helloo how r u
today is sunday
k we will go out
what u r doing here
shall we go to home
k we will meet later
i will call u tonite
shall we go out
bash-3.00$ cat line.sh
#!/bin/bash
i=0
while read -r LINE
do
if [ "$i" -eq 3 ];then
echo ""
i=0
else
echo "$LINE"
((i++))
fi
done < "test"
output
-bash-3.00$ bash line.sh
hi how u doing
hi helloo how r u
today is sunday
what u r doing here
shall we go to home
k we will meet later
shall we go out
my excepted output is
hi how u doing
hi helloo how r u
today is sunday
k we will go out
what u r doing here
shall we go to home
k we will meet later
i will call u tonite
shall we go out
#!/bin/bash
i=0
while read -r LINE
do
((i++))
echo "$LINE"
if [ "$i" -eq 3 ];then
echo ""
i=0
fi
done < "file"
same output is coming . it delete the line after 3rd line and make it as a line space
#> cat file
hi how u doing
hi helloo how r u
today is sunday
k we will go out
what u r doing here
shall we go to home
k we will meet later
i will call u tonite
take of ur pets
#> ./myscript.sh
hi how u doing
hi helloo how r u
today is sunday
k we will go out
what u r doing here
shall we go to home
k we will meet later
i will call u tonite
take of ur pets
thanks a lot kurumi , its working . . .