Looking for sed commands to add some strings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Looking for sed commands to add some strings
# 1  
Old 09-18-2015
Looking for sed commands to add some strings

Hi All,

I have one file which has contents as following. I have now to add some strings into this file. In below there is a "Description" field, and I have to look line by line and as the description contents will be finished, I have to add the string "Hello world" followed by a TAB. So before the filed "Jobs" I have to add the string "Hello world" followed by a TAB.

Code:
Change:    12345

Date:    2015/09/10 10:08:59

Client:    maven

User:    xyz

Status:    submitted

Description:
               test file.

Jobs:
    XY-245


Moderator's Comments:
Mod Comment Use code tags please, thanks.

Last edited by Don Cragun; 09-18-2015 at 03:48 PM.. Reason: Fix CODE tags again.
# 2  
Old 09-18-2015
Is this a homework assignment?

Homework and coursework questions can only be posted in this forum under special homework rules.

If this is homework, please repost in the Homework and Coursework Forum. If not, please explain why you are trying to do this.
# 3  
Old 09-18-2015
So, based on the discussion in your other thread, assuming that this isn't homework either; please show us what you have tried and (in CODE tags) please show us the output you are trying to produce. (Your description can be interpreted several ways as to where the text you want to add is supposed to appear. And, some are easier to apply than others.)

It always helps if you also tell us what operating system you're using and it is especially important with sed since some operating systems extend the behavior specified by the standards for sed in various incompatible ways.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

sed find 2 strings and replace one

Hi Everyone, I want to find this 2 strings in a single line a file and replace the second string. this is the line i need to find <param name="user" value="CORE_BI"/> find user and CORE_BI and replace only CORE_BI with admin so finally the line should look like this. <param... (5 Replies)
Discussion started by: shajay12
5 Replies

2. UNIX for Beginners Questions & Answers

Can I combine below mentioned grep commands using OR (when searching strings having spaces)

Command 1: $script | grep 'Write to ECC( SSID=MARGIN)' Command 2: $script | grep 'is not greater than existing logical processing' The above commands run my script and search the mentioned strings but I do not want to run my script twice. It is increasing run time. Can someone tell me... (3 Replies)
Discussion started by: Tanu
3 Replies

3. Shell Programming and Scripting

Delete 2 strings from 1 line with sed?

Hi guys, I wonder if it's possible to search for a line containing 2 strings and delete that line and perhaps replace the source file with already deleted line(s). What I mean is something like this: sourcefile.txt line1: something 122344 somethin2 24334 45554676 line2: another something... (6 Replies)
Discussion started by: netrom
6 Replies

4. Shell Programming and Scripting

sed to extract all strings

Hi, I have a text file containing 2 lines as follows: I'm trying to extract all the strings following an "AME." The output would be as follows: BUSINESS_UNIT PROJECT_ID ACTIVITY_ID RES_USER1 RESOURCE_ID_FROM ANALYSIS_TYPE BI_DISTRIB_STATUS BUSINESS_UNIT PROJECT_ID ACTIVITY_ID... (5 Replies)
Discussion started by: simpletech369
5 Replies

5. Shell Programming and Scripting

Using sed to replace two different strings?

Hey everyone! Simple question - I am trying to use sed to replace two different strings. As it stands I can implement this as: sed -i 's/TIMEOUT//g' sed -i 's/null//g' And it works. However, is it possible to shrink that down into a single command? Will there be any performance benefits? (3 Replies)
Discussion started by: msarro
3 Replies

6. Shell Programming and Scripting

Comparing strings with sed

Input: The the the the Output: not-same same What would be the sed command to do this? (7 Replies)
Discussion started by: cola
7 Replies

7. Shell Programming and Scripting

Replace Strings with sed or awk

Hello i need some help with the usage of sed. Situation : 2 textfiles, file.in , file.out In the first textfile which is called file.in are the words for the substitution. Every word is in a new-line like : Firstsub Secondsub Thridsub ... In the second textflie wich is called file.out is... (5 Replies)
Discussion started by: Kingbruce
5 Replies

8. Shell Programming and Scripting

replacing strings with newlines : sed

Hi everyone, Since the previous time I received help from unix.com I have been encouraged to learn more. going through 1 of the articles(View Article) on sed I found, it pointed an interesting situation. Suppose the text is : Romeo and Ethel the Dancer Moves Audience to Tears. I... (3 Replies)
Discussion started by: hkansal
3 Replies

9. Shell Programming and Scripting

Using sed with strings of nonprintable characters

Hey, I'm having trouble figuring out the syntax for using sed with string of non-printable characters. What I have is the following format: <field>@@;@@<field>@@;@@...@@;@@<field>@@^@@<field>@@;@@<field>@@;@@...@@;@@<field>@@^@@ ... With the @@;@@ being the delimeters between fields and the... (3 Replies)
Discussion started by: Dickalicious
3 Replies

10. UNIX for Dummies Questions & Answers

Collating strings using sed

I am trying to work out how to collate a string in sed. The format is... 01 R W R D But i want it to sort like so... 01 RRWD i have tried regular expressions on this but because their are many different ways this string could appear, it is not working out. Does anyone know a method of doing... (3 Replies)
Discussion started by: jeffersno1
3 Replies
Login or Register to Ask a Question