Sponsored Content
Top Forums Shell Programming and Scripting Need to add prefix using sed or awk from cat the file Post 303006119 by RudiC on Friday 27th of October 2017 07:47:18 AM
Old 10-27-2017
This problem has been solved umpteen times in these fora. Did you bother to do a search as recommended in the rules?

However, try
Code:
awk 'NF == 1 {PRFX = $1; next} {print PRFX "," $0}' file
Node1,TDEV RW 1035788
Node1,TDEV RW 1035788
Server1,TDEV RW 69053
Server2,TDEV RW 69053
Server2,TDEV RW 103579
Server3,TDEV RW 69053
server4,RDF1+TDEV RW 69053
server4,RDF1+TDEV RW 517894
server4,RDF1+TDEV RW 621473
server6,TDEV RW 34526
server6,TDEV RW 34526
server6,RDF1+TDEV RW 34526
server6,RDF1+TDEV RW 34526
server6,TDEV RW 34526


Last edited by RudiC; 10-30-2017 at 10:04 AM.. Reason: Typo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem to add the string(without sed & awk) into the middle of file

Hi, I have tried many times to add the string into the first line of the file or the middle of the file but could not find the solution. I first tried by $echo "paki" >> file This code only append paki string at the end of file "file" but how can i add this "paki" into the first line or... (5 Replies)
Discussion started by: ali hussain
5 Replies

2. UNIX for Dummies Questions & Answers

tr, sed, awk, cat or scripting

I need to change all Newline caracters (\12) to Fieldseparator(\34). tr -A '\12' '\34' <file1> file2 Replace all delete (\177) with Newline (\12) tr -A '\177' '\12' <file2> file3 Put the name of the file first in all rows. awk '{printf "%s\34%s\n", FILENAME,$0} file3 > file4 So far no... (6 Replies)
Discussion started by: MrKlint
6 Replies

3. Shell Programming and Scripting

Remove prefix using awk

Remove prefix using awk File: nawk -F"|" '{if ($1 ~ /^xyz./) print; else { gsub(.*\..*, \..*, $1) ;print }}' file Error: ouput required: (5 Replies)
Discussion started by: pinnacle
5 Replies

4. Shell Programming and Scripting

Need awk script to add a prefix to each line in file

Hello , I have file with below content : '165567885', '165568443', '165568805', I need an awk script that would add a prefix zero after first ' . Like '0165567885', '0165568443', '0165568805', Please help. Thanks in advance. (5 Replies)
Discussion started by: rmv
5 Replies

5. Shell Programming and Scripting

awk or sed to add field in a text file

Hi there, I have a csv file with some columns comma sepated like this : 4502-17,PETER,ITA2,LEGUE,92,ME - HALF,23/05/10 15:00 4502-18,CARL,ITA2,LEGUE,96,ME - HALF,20/01/09 14:00 4502-19,OTTO,ITA2,LEGUE,97,ME - MARY,23/05/10 15:00 As you can see the column n. 7 is a timestamp column, I need... (23 Replies)
Discussion started by: capnino
23 Replies

6. Linux

Adding a prefix to a column using awk/sed commands

Hello, I am a newbie to linux and struggling to find a better way to append a column in a text file. Here is the file i want to modify: It has 8 columns (and thousands of rows). I want to append the first column by adding "chr" infront of the numbers. Some rows have a string in the first... (4 Replies)
Discussion started by: bjorngill
4 Replies

7. UNIX for Dummies Questions & Answers

How to pass cat file in awk statement?

Hi, I am working on kernel parameters, want to check values under /proc/sys/kernel below I tried for kernel.sem SEMMNS: 4096 cat /proc/sys/kernel/sem | awk '{print $2}' awk '{ if ($2 < 33000) print }' /proc/sys/kernel/sem |awk '{print $2}' 32000 The above... (7 Replies)
Discussion started by: stew
7 Replies

8. Shell Programming and Scripting

Extract Uniq prefix from a start and end prefix

Dear All, assume i have a file with content: <Start>6000</Start> <Stop>7599</Stop> the output is: 6000 7000 7100 7200 7300 7400 7599 how should we use any awk, sed, perl can do this task, means to extract the uniq prefixes from the start and stop prefix. Thanks Jimmy (3 Replies)
Discussion started by: jimmy_y
3 Replies

9. Shell Programming and Scripting

awk move select fields to match file prefix in two directories

In the awk below I am trying to use the file1 as a match to file2. In file2 the contents of $5,&6,and $7 (always tab-delimited) and are copied to the output under the header Quality metrics. The below executes but the output is empty. I have added comments to help and show my thinking. Thank you... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. Shell Programming and Scripting

Add the word "prefix" to beginning of line using sed

SUSE linux bash shell this works test -d /tmpp && echo "directory exists" || echo "directory doesn't exists" |sed -e "s/^/prefix /" prefix directory doesn't exists but why doesn't this work? test -d /tmp && echo "directory exists" || echo "directory doesn't exists" |sed -e... (3 Replies)
Discussion started by: snoman1
3 Replies
NMSSTORE2DLF.IN(1)					  LogReport's Lire Documentation					NMSSTORE2DLF.IN(1)

NAME
nmsstore2dlf - convert Netscape Messaging Server IMAP or POP log files to the Lire msgstore DLF SYNOPSIS
nmsstore2dlf DESCRIPTION
This program converts Netscape Messaging Server log files generated by the IMAP or POP services to the Lire msgstore DLF. LIMITATIONS
In order to have this parser giving you useful information it is recommended to set the NMS 4 logs at the right level. In order to fix that problem please make sure you did the following. Go on the Netscape Messaging Server 4 Message Store Become the Mail Server user (usually this should not be root but typically a user like mailsrv or whatever was defined at installation time, check for the ownership of the files in your message server instance for example) Go to the right location, something like: server-root/msg-instance For example it could be: /usr/netscape/server4/msg-mymailserver Do: $ ./configutil -o logfile.pop.loglevel -v Informational OK SET $ ./configutil -o logfile.imap.loglevel -v Informational OK SET Then become root, go again to your instance directory like: /usr/netscape/server4/msg-mymailserver and do: # ./stop-msg pop /mailserv1fs/netscape/server4: Stopping POP3 daemon 24789 .... done: 24789 # ./start-msg pop /mailserv1fs/netscape/server4: Starting POP3 daemon .... done: 17509 EXAMPLES
To process a log as produced by Netscape Messaging Server: $ nmsstore2dlf < ns-store.log nmsstore2dlf will be rarely used on its own, but is more likely called by lr_log2report: $ lr_log2report nmsstore < /var/log/ns-store.log > report VERSION
$Id: nmsstore2dlf.in,v 1.9 2006/07/23 13:16:35 vanbaal Exp $ THANKS
Jean-Yves Monnier for supplying a patch. AUTHORS
Arnaud Taddei <Arnaud.Taddei@sun.com>, Arnaud Gaillard <Arnaud.Gaillard@orange.ch>, Elie Dufraiche <Elie.Dufraiche@sun.com> COPYRIGHT
Copyright (C) 2002 Arnaud Taddei <Arnaud.Taddei@sun.com>, Arnaud Gaillard <Arnaud.Gaillard@orange.ch>, Elie Dufraiche <Elie.Dufraiche@sun.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html. Lire 2.1.1 2006-07-23 NMSSTORE2DLF.IN(1)
All times are GMT -4. The time now is 04:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy