Sponsored Content
Top Forums Shell Programming and Scripting Insert text with Sed (in various positions) Post 302487414 by </kida> on Wednesday 12th of January 2011 10:47:01 AM
Old 01-12-2011
Insert text with Sed (in various positions)

Hello. I'm trying to insert text in various positions and I could only do that using pipes for each position.

Example:
Code:
cat file | sed -e 's#\(.\{5\}\)\(.*\)#\1:\2#g' | sed -e 's#\(.\{26\}\)\(.*\)#\1:\2#g'

Insert ":" at position 5 and 26.

it can be done in the same sentence, without using pipes?

Help please. Thanks.

Last edited by Scott; 01-12-2011 at 11:53 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Insert Text With Sed

Hello. Trying to insert text at line 1 and after last line of file. I have searched posts but nothing seems to work. I keep getting extra characters error or nothing gets inserted into the file. #!/bin/sh touch textfile.txt sed 'i\ Add this line before every line with WORD' textfile.txt ... (5 Replies)
Discussion started by: steveramsey
5 Replies

2. Shell Programming and Scripting

Need to insert new text and change existing text in a file using SED

Hi all, I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output. sed '$a\ hi... ' shell > shell1 But I face problem when using the same in script. It is throwing the error as, sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies

3. Shell Programming and Scripting

sed insert text at particular line

I know that sed -n '12p' file will print line 12 but how might I insert text to a specified line? thanks (2 Replies)
Discussion started by: action_owl
2 Replies

4. UNIX for Dummies Questions & Answers

Insert Commas at fixed positions

Hi I have a text file which is position delimited, i.e. Code1 Description1 Value1 Code2 Description2 Value2 etc. I want to import this file into MySQL so I want to convert the file into Comma delimited format. To do this I want to insert commas at fixed positions on... (7 Replies)
Discussion started by: arossco
7 Replies

5. Shell Programming and Scripting

sed insert text without newline

Hi, I use sed to insert text at beginning of a file. But sed inserts a newline after my text that I do not need. For example, I want to insert "foo" at the beginning of my file: > cat myfile This is first line. > sed -i '1i\foo' myfile > cat myfile foo This is first line. ... (5 Replies)
Discussion started by: tdw
5 Replies

6. Shell Programming and Scripting

sed to insert a slash and keep text

I have: /path/to/my/fixdir/MD1234567.tar I want to have: /path/to/my/fixdir/MD/1234567.tar fixdir never changes but MD does and how many numerical digits does. I want something like: /usr/bin/sed 's/fixdir\/../fixdir\/..\//' This ends up: /path/to/my/fixdir/../1234567.tar But... (3 Replies)
Discussion started by: crowman
3 Replies

7. Shell Programming and Scripting

Insert text using sed

sed 's/$/TEST/g' will insert TEST at the end of each line. i want to insert TEST at column 64 (7 Replies)
Discussion started by: lawsongeek
7 Replies

8. Shell Programming and Scripting

How do I insert text with sed ?

Hi I was wondering if anyone new of a solution to this problem? I need to copy a time stamp that is on a line of .text in a text file into multiple positions on the same line. I need to insert the time stamp on the same line between every occurance of the text ".pdf_.html" right after the... (9 Replies)
Discussion started by: Paul Walker
9 Replies

9. Shell Programming and Scripting

Sed; insert text two lines above match

Hi! Considering below text, how would I use sed to insert text right below the v0005-line, using the SEPARATOR-line as a pattern to search for, so two lines above the separator? I can do it right above the separator, but not 2 lines... # v0004 - Some text # v0005 - More text #... (5 Replies)
Discussion started by: indo1144
5 Replies

10. Shell Programming and Scripting

Using sed to insert text between lines

Hello, I am trying to insert a section of text between lines in another text file. The new lines to be inserted are: abcd.efgh.zzzz=blah abcd.efgh.xxxx=blah Where N = 0 to 2 Original File: abcd.efgh.wwxx=aaaaa abcd.efgh.yyzz=bbbbb abcd.efgh.wwxx=aaaaa abcd.efgh.yyzz=bbbbb... (3 Replies)
Discussion started by: tsu3000
3 Replies
TS_PACKET_INSERT(1)						   User Commands					       TS_PACKET_INSERT(1)

NAME
ts_packet_insert - insert packets into a Transport Stream DESCRIPTION
Usage: ts_packet_insert [switches] <infile> [switches] Insert TS packets into a Transport Stream at a positions specified by the user. Input: <infile> A H.222.0 TS stream. Switches: -p [positions] This a a colon (':') delimited string of numbers between 0 and 1, representing how far through to put each ts packet. E.g. -p 0.1:0.4:0.7:0.9 will insert 4 packets at 10%, 40%, 70% and 90% through the file. -pid [pid] The inserted packets will have the pid specfied. -s [string] The inserted packets will contain [string] as it's payload. -o [output file] The new TS file will be written out to the file specified. (defaults to out.ts) -h (--help) This message. Example: ts_packet_insert -p 0.3:0.6 -o out.ts -pid 89 -s "AD=start" in.ts ts_packet_insert [switches] <infile> [switches] Insert TS packets into a Transport Stream at a positions specified by the user. Input: <infile> A H.222.0 TS stream. Switches: -p [positions] This a a colon (':') delimited string of numbers between 0 and 1, representing how far through to put each ts packet. E.g. -p 0.1:0.4:0.7:0.9 will insert 4 packets at 10%, 40%, 70% and 90% through the file. -pid [pid] The inserted packets will have the pid specfied. -s [string] The inserted packets will contain [string] as it's payload. -o [output file] The new TS file will be written out to the file specified. (defaults to out.ts) -h (--help) This message. Example: ts_packet_insert -p 0.3:0.6 -o out.ts -pid 89 -s "AD=start" in.ts SEE ALSO
The full documentation for ts_packet_insert is maintained as a Texinfo manual. Please check http://tstools.berlios.de for more informa- tion. ts_packet_insert 1.11 November 2008 TS_PACKET_INSERT(1)
All times are GMT -4. The time now is 09:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy