space between two lines


 
Thread Tools Search this Thread
Operating Systems Solaris space between two lines
# 8  
Old 07-13-2010
Code:
#!/bin/bash

i=0
while read -r LINE
do
  ((i++))
  echo "$LINE"
  if [ "$i" -eq 3 ];then
    echo ""
    i=0
  fi
done < "file"

This User Gave Thanks to kurumi For This Post:
# 9  
Old 07-13-2010
Quote:
Originally Posted by kurumi
Code:
#!/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
# 10  
Old 07-13-2010
Code:
#> 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

# 11  
Old 07-13-2010
Quote:
Originally Posted by kurumi
Code:
#!/bin/bash
 
i=0
while read -r LINE
do
  ((i++))
  echo "$LINE"
  if [ "$i" -eq 3 ];then
    echo ""
    i=0
  fi
done < "file"


thanks a lot kurumi , its working . . .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep line with all string in the lines and not space.

I want to write the syntax so does not count line with no space. So currerntly it is showing lines as 5, but i want to show 4. # cat /tmp/mediacheck | sort -u | grep -vi " " | awk '{print $1}' | wc -l BA7552 BAA002 BAA003 BAA004 (6 Replies)
Discussion started by: Junes
6 Replies

2. UNIX Desktop Questions & Answers

Adding lines to pattern space

Is there any way to add lines to the pattern space of sed? I know a bit about the N flag, but am not able to use it to do what I want which is: read a file n lines at a time. If I find a match I quit else move to the next line. e.g. if I am looking for the following three lines Hello How... (2 Replies)
Discussion started by: jawsnnn
2 Replies

3. Shell Programming and Scripting

Extract lines between 2 strings add white space

I'm trying to extract all the lines between 2 strings (including the lines containing the strings) To make the strings unique I need to include white space if possible. I'm not certain how to do that. sed -n '/ string1 /,/string2/p' infile > outfile & (4 Replies)
Discussion started by: dcfargo
4 Replies

4. Shell Programming and Scripting

Break lines up into single lines after each space in every line

It sounds a bit confusing but what I have is a text file like the example below (without the Line1, Line2, Line3 etc. of course) and I want to move every group of characters into a new line after each space. Example of text file; line1 .digg-widget-theme2 ul { background: rgb(0, 0, 0) none... (7 Replies)
Discussion started by: lewk
7 Replies

5. Shell Programming and Scripting

Removing empty lines(space) between two lines containing strings

Hi, Please provide shell script to Remove empty lines(space) between two lines containing strings in a file. Input File : A1/EXT "BAP_BSC6/07B/00" 844 090602 1605 RXOCF-465 PDTR11 1 SITE ON BATTERY A2/EXT... (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

6. Shell Programming and Scripting

Breaking long lines into (characters, newline, space) groups

Hello, I am currently trying to edit an ldif file. The ldif specification states that a newline followed by a space indicates the subsequent line is a continuation of the line. So, in order to search and replace properly and edit the file, I open the file in textwrangler, search for "\r " and... (14 Replies)
Discussion started by: rowie718
14 Replies

7. Shell Programming and Scripting

Remove white space at the beginning of lines

Hi! I store some data obtained with grep or awk in a file. The problem is that some lines have white space at the begining : line1 line2 line3 I use something like grep WORD INFILE >> OUTFILE awk >> OUTFILE I would love if it were possible to remove the white whitout parsing the... (4 Replies)
Discussion started by: tipi
4 Replies

8. Shell Programming and Scripting

Find lines with space between strings

Hello all, I am having trouble with setting up a regular expression used with egrep. My script reads an input file a line at a time. I would like the egrep command to search for the following pattern: server name at the beginning of the line, then one or more spaces, and then a pound sign. ... (5 Replies)
Discussion started by: Galt
5 Replies

9. UNIX for Advanced & Expert Users

Add new lines with a space in beginning

Hi file1.txt contains GigabitEthernet1/1 GigabitEthernet1/2 GigabitEthernet2/2 GigabitEthernet2/4 GigabitEthernet2/14 GigabitEthernet2/16 can anyone show me how to modify it as below. there is a space at the beginning of the next two lines . ie 'no shut' and 'switch..' !... (8 Replies)
Discussion started by: Aejaz
8 Replies

10. Shell Programming and Scripting

re: removing trailing space from lines

Not sure why this thread was closed without any explanation, but you can do what you're asking with sed 's/]*$//g' < sourceFile > destFile (1 Reply)
Discussion started by: oombera
1 Replies
Login or Register to Ask a Question