new line after specific number character


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting new line after specific number character
# 1  
Old 02-06-2012
new line after specific number character

Hi All, I have input file like this:

input1:

Code:
             ( 1083479)=T 158V 1798,
T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,T 4152V 3495,T 5500V 3631,
             ( 1083501)=T 181V 1851,
T  459V 1954,T  810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,T 4799V 3640,




output1:

Code:

                   ( 1083479)=T 158V 1798,
      T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,
      T 4152V 3495,T 5500V 3631,
                   ( 1083501)=T 181V 1851,
      T  459V 1954,T  810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,
      T 4799V 3640,


# 2  
Old 02-06-2012
can u pls exaplain what exactly you needed
# 3  
Old 02-06-2012
Code:
man fold

?
# 4  
Old 02-06-2012
Quote:
Originally Posted by kalpeer
can u pls exaplain what exactly you needed

Hello Kalpeer,

I want to enter line after 65th character, then insert 6 space before each line.

Input1:
Code:
             ( 1083479)=T 158V 1798,
T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,T 4152V 3495,T 5500V 3631,
             ( 1083501)=T 181V 1851,
T  459V 1954,T  810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,T 4799V 3640,


desire output:

Code:
                   ( 1083479)=T 158V 1798,
      T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,
      T 4152V 3495,T 5500V 3631,
                   ( 1083501)=T 181V 1851,
      T  459V 1954,T  810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,
      T 4799V 3640,


thanks for andvance

-attila
# 5  
Old 02-06-2012
Code:
fold -w 65 input1 | sed 's/^/      /' >output1

Code:
$ cat tst
             ( 1083479)=T 158V 1798,
T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,T 4152V 3495,T 5500V 3631,
             ( 1083501)=T 181V 1851,
T  459V 1954,T  810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,T 4799V 3640,

Code:
$ fold -w 65 tst | sed 's/^/      /'
                   ( 1083479)=T 158V 1798,
      T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,
      T 4152V 3495,T 5500V 3631,
                   ( 1083501)=T 181V 1851,
      T  459V 1954,T  810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,
      T 4799V 3640,


Last edited by ctsgnb; 02-06-2012 at 06:16 AM..
# 6  
Old 02-06-2012
Code:
var="..................................."
echo "( 1083479)=T 158V 1798, T  391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,T 4152V 3495,T 5500V 3631" | sed "s/$var/& \n/g" | sed "s/^./      /"

output:
Code:
                1083479)=T 158V 1798, T  391V 189
              ,T 1138V 2273,T 1547V 2477,T 2249V
             2917,T 3278V 3234,T 4152V 3495,T 5
             00V 3631


Last edited by Franklin52; 02-06-2012 at 06:52 AM.. Reason: Please use code tags for data and code samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to insert new line after a specific character in scripts?

Hi, I'm trying to add a new line after finding a specific String. That is my string: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html and I want to change that file to: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html extra_hosts: -... (4 Replies)
Discussion started by: siamak
4 Replies

2. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

3. Shell Programming and Scripting

Remove line with specific character

HI Input :- Aog:0rt__dev_8 LAAXU24 vs.3 LAA40l0 ** LAAXU241 ** Output :- Aog:0rt__dev_8 LAAXU24 vs.3 Delete the line with ** (3 Replies)
Discussion started by: pareshkp
3 Replies

4. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. Shell Programming and Scripting

Cut from specific line number to a line number

Hi All, I've a file like this.. Sheet1 a,1 a,2 a,3 a,4 a,5 Sheet2 a,6 a,7 a,8 a,9 a,10 Sheet3 a,11 a,12 a,13 (7 Replies)
Discussion started by: manab86
7 Replies

6. Shell Programming and Scripting

Add new line before specific character

hello all, I have file like this "infile.txt" (all data in one line) A240 582247.99974288.7 8.0 239 582248.19974301.1 8.0 238 582248.39974313.6 8.01A 237 582248.49974326.1 8.0 236 582248.69974338.6 8.0 235 582248.79974351.1 8.01A 234 582248.99974363.5 8.0 233 582249.19974376.0 8.0 232... (4 Replies)
Discussion started by: attila
4 Replies

7. Shell Programming and Scripting

Extract character between specific line numbers

Hi guys, I have txt file and I would need to extract all the contents between specific line numbers. Line 1: apple Line 2: orange Line 3: mango Line 4: grapes Line 5: pine apple I need to extract the content between line 2 and 4, including the contents of Line 2 and 4 so the ouput... (2 Replies)
Discussion started by: gowrishankar05
2 Replies

8. Shell Programming and Scripting

How to append a character to the last but one field on a specific line?

Hi Guys, I have a file like this: aaa b c d e f fsss g h i k l qqq r t h n I want: aaa b c d e f fsss g h i k l qqq r t h , n ggg p t e d u qqq i o s , k (2 Replies)
Discussion started by: npatwardhan
2 Replies

9. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

10. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies
Login or Register to Ask a Question