Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search a file for certain strings and add them to the end of certain lines Post 302941975 by Angela S on Thursday 23rd of April 2015 09:25:22 AM
Old 04-23-2015
Search a file for certain strings and add them to the end of certain lines

I have a log file which lists groups and users in the following format

Code:
GROUP1
user1
user2
user3
GROUP2
user4
user5
user6
GROUP3
user7
user8

I need to change the format to:

Code:
user1|GROUP1
user2|GROUP1
user3|GROUP1
user4|GROUP2
user5|GROUP2
user6|GROUP2
user7|GROUP3
user8|GROUP3

Does anybody know how I should approach this?

Thanks


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

Last edited by zaxxon; 04-23-2015 at 10:31 AM..
 

10 More Discussions You Might Find Interesting

1. HP-UX

Add a column at the end of all the lines in a file

Hi Guys, :D I am very much new to UNIX. I dont have much basics of coding in UNIX, so please help me out of thi ssituation. I have a file say for ex: ABC.dtd and it contains "|" delimited data as test1|testing|test3|moving past1|runing|test4|going I need to add a column at the end... (6 Replies)
Discussion started by: ruthless
6 Replies

2. Shell Programming and Scripting

different take on common ?: search for two strings and remove lines between them

Thank you for assisting, I've got a partial solution just needs a tweak. Hulk-BASH$ cat somefile.txt oh there is some stuff here some more stuff here START_LABEL stuff I want more stuff I want END_LABEL other stuff here too and even more stuff here too Hulk-BASH$ Hulk-BASH$ sed... (8 Replies)
Discussion started by: laser
8 Replies

3. Shell Programming and Scripting

awk how to search strings within a file from two different lines

Hi, i would really appreciate any help anyone can give with the following info. Thanks in advance. I need to run a search on a file that contains thousands of trades, each trade is added into the file in blocks of 25 lines. i know the search has to take place between a time stamp specified... (4 Replies)
Discussion started by: sp3arsy
4 Replies

4. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

5. Programming

search a file between two begin and end strings in c

Can any one help me out with following problem... I want to search in a file which has two strings repeat each time(like start and end) i want to search between these two string in C programming. please help me with the solution. thanks in advance. (8 Replies)
Discussion started by: uday.sena.m
8 Replies

6. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

7. Shell Programming and Scripting

awk to search similar strings and add their values

Hi, I have a text file with the following content: monday,20 tuesday,10 wednesday,29 monday,10 friday,12 wednesday,14 monday,15 thursday,34 i want the following output: monday,45 tuesday,10 wednesday,43 friday,12 (3 Replies)
Discussion started by: prashu_g
3 Replies

8. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

9. UNIX for Dummies Questions & Answers

Add strings from one file at the end of specific lines in text file

Hello All, this is my first post so I don't know if I am doing this right. I would like to append entries from a series of strings (contained in a text file) consecutively at the end of specifically labeled lines in another file. As an example: - the file that contains the values to be... (3 Replies)
Discussion started by: gus74
3 Replies

10. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies
SMPTEFrame(3)							    libltcsmpte 						     SMPTEFrame(3)

NAME
SMPTEFrame - Raw 80 bit SMPTE frame. SYNOPSIS
#include <ltcsmpte.h> Data Fields unsigned int frameUnits:4 unsigned int user1:4 unsigned int frameTens:2 unsigned int dfbit:1 unsigned int colFrm:1 unsigned int user2:4 unsigned int secsUnits:4 unsigned int user3:4 unsigned int secsTens:3 unsigned int biphaseMarkPhaseCorrection:1 unsigned int user4:4 unsigned int minsUnits:4 unsigned int user5:4 unsigned int minsTens:3 unsigned int binaryGroupFlagBit1:1 unsigned int user6:4 unsigned int hoursUnits:4 unsigned int user7:4 unsigned int hoursTens:2 unsigned int reserved:1 unsigned int binaryGroupFlagBit2:1 unsigned int user8:4 unsigned int syncWord:16 Detailed Description Raw 80 bit SMPTE frame. Definition at line 140 of file ltcsmpte.h. Field Documentation unsigned int SMPTEFrame::binaryGroupFlagBit1 Definition at line 160 of file ltcsmpte.h. unsigned int SMPTEFrame::binaryGroupFlagBit2 Definition at line 168 of file ltcsmpte.h. unsigned int SMPTEFrame::biphaseMarkPhaseCorrection Definition at line 153 of file ltcsmpte.h. unsigned int SMPTEFrame::colFrm Definition at line 146 of file ltcsmpte.h. unsigned int SMPTEFrame::dfbit Examples: tests/decoder.c. Definition at line 145 of file ltcsmpte.h. unsigned int SMPTEFrame::frameTens Definition at line 144 of file ltcsmpte.h. unsigned int SMPTEFrame::frameUnits Definition at line 141 of file ltcsmpte.h. unsigned int SMPTEFrame::hoursTens Definition at line 166 of file ltcsmpte.h. unsigned int SMPTEFrame::hoursUnits Definition at line 163 of file ltcsmpte.h. unsigned int SMPTEFrame::minsTens Definition at line 159 of file ltcsmpte.h. unsigned int SMPTEFrame::minsUnits Definition at line 156 of file ltcsmpte.h. unsigned int SMPTEFrame::reserved Definition at line 167 of file ltcsmpte.h. unsigned int SMPTEFrame::secsTens Definition at line 152 of file ltcsmpte.h. unsigned int SMPTEFrame::secsUnits Definition at line 149 of file ltcsmpte.h. unsigned int SMPTEFrame::syncWord Definition at line 171 of file ltcsmpte.h. unsigned int SMPTEFrame::user1 Definition at line 142 of file ltcsmpte.h. unsigned int SMPTEFrame::user2 Definition at line 147 of file ltcsmpte.h. unsigned int SMPTEFrame::user3 Definition at line 150 of file ltcsmpte.h. unsigned int SMPTEFrame::user4 Definition at line 154 of file ltcsmpte.h. unsigned int SMPTEFrame::user5 Definition at line 157 of file ltcsmpte.h. unsigned int SMPTEFrame::user6 Definition at line 161 of file ltcsmpte.h. unsigned int SMPTEFrame::user7 Definition at line 164 of file ltcsmpte.h. unsigned int SMPTEFrame::user8 Definition at line 169 of file ltcsmpte.h. Author Generated automatically by Doxygen for libltcsmpte from the source code. Version 0.4.4 Fri Apr 27 2012 SMPTEFrame(3)
All times are GMT -4. The time now is 04:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy