Sponsored Content
Top Forums Shell Programming and Scripting Append has prefix in while loop Post 303040830 by ranjancom2000 on Thursday 7th of November 2019 11:35:53 AM
Old 11-07-2019
Append has prefix in while loop

I was using below script to grep one file. I need to append the output using prefix

Data of all-Vms-1.txt
Code:
server-1 frame-1 LUN001
server-2 frame-1 LUN002

Data of all-vm-unix.txt

Code:
server-1     24
server-2     50

Script used
Code:
while read -r g h ;
do
cat all-Vms-1.txt |grep -i $g |awk '$0="frame "$0'|sed -e "s/frame/${g} ${h}/" >> all-vm-unix-with-vc-2

done < all-vm-unix.txt

I need output like this

Code:
server-1 24 server-1 frame-1 LUN001
server-2 50 server-2 frame-1 LUN002

But Now it was echo in next line

Code:
server-1 24 
server-1 frame-1 LUN001
server-2 50 
server-2 frame-1 LUN002


Last edited by Scrutinizer; 11-08-2019 at 05:00 AM.. Reason: quote tags -> code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

remove filename prefix

I've got a bunch of files called oldabc, olddef etc. i want to copy these to be abc, def.... I can do this with file extensions....but can get the logic to work for prefixes. All the files I am interested in have a prefix of 'old'. This loop is no good for me....it looks at the content... (2 Replies)
Discussion started by: peter.herlihy
2 Replies

2. Shell Programming and Scripting

Need to replace a . with / which is having a matching Prefix

Hi Input File: export NAME='AA.BB.CC' export FILE=1.2.3 AA.BB.CC export MAIL= '1.3.3' export char='XX.YY.ZZ' Out File export NAME='AA/BB/CC' export FILE=1.2.3 AA.BB.CC export MAIL= '1.3.3' export char='XX/YY/ZZ' Only the Lines which have export and have alphabets after =... (9 Replies)
Discussion started by: pbsrinivas
9 Replies

3. Shell Programming and Scripting

prefix suffix to each argument

Hi, I have a variable, which contains comma separated values. Something like. StringA="abc,def,ghi,jkl" I want to apply prefix and suffix to each value in the string without using any loops. Say if Prefix is Pre_ and Suffix is _Suf then I need to get ... (1 Reply)
Discussion started by: tostay2003
1 Replies

4. UNIX for Dummies Questions & Answers

how to cut prefix from a string

I have a file: chromosome1:436728 chromosome2:32892 ..... chromosome22:23781 I just want to get the number, not the prefix "chromosomeX", so I want to remove all the prefix ahead of the numbers. How can I do that?? Thanks!!! (PS: give me some very simple command so that I can understand... (4 Replies)
Discussion started by: kaixinsjtu
4 Replies

5. UNIX for Dummies Questions & Answers

--prefix question

OK, now I just feel plain silly asking this. But I am very much a beginner at compiling and installing Unix software, so... When setting the prefix, do you also have to specify the directory the files reside in? For example, lets say I am installing cURL in /usr/local Would I set the prefix... (1 Reply)
Discussion started by: RobertSubnet
1 Replies

6. UNIX for Dummies Questions & Answers

What prefix backslash does to command

In unix when I run rm command, it asks for file removal confirmation e.g. rm netmail_log.csv rm: remove netmail_log.csv (yes/no)? n But if i prefix backslash to rm it does not ask for confirmation. Does anyone know what backslash does to command or shell ? e.g. \rm netmail_log.csv (1 Reply)
Discussion started by: Devdatta
1 Replies

7. Shell Programming and Scripting

append to same string variable in loop

I want to append values to same string variable inside a recursive function that I have .. I do not want to write to any file but use a variable.. Can anyone please help with it? Thanks in advance. (6 Replies)
Discussion started by: Prev
6 Replies

8. Shell Programming and Scripting

Find all images, append unique prefix to name and move to different directory

Hi, I have a directory with Multiple subdirectories and 1000s of pictures (jpg) in each directory. The problem is that each directory has a 001.jpg in them. I want to append a unique name (the directory_name)would be fine. and then move them to one main backup directory once they have been... (1 Reply)
Discussion started by: kmaq7621
1 Replies

9. Shell Programming and Scripting

Removing only Prefix string (!)

Hello everyone, I want to remove only prefix ME_ from all the values that are present in the FILEA. Below code I'm using for this. sed 's/ME\_//g' FILEA > FILEB Using the above code, all ME_ values are getting removed from the file. But the problem here is I want to remove only Prefix ME_... (4 Replies)
Discussion started by: ed_9
4 Replies

10. 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
EMACSCLIENT(1)						      General Commands Manual						    EMACSCLIENT(1)

NAME
emacsclient - tells a running Emacs to visit a file SYNOPSIS
emacsclient [options] files ... DESCRIPTION
This manual page documents briefly the emacsclient command. Full documentation is available in the GNU Info format; see below. This man- ual page was originally written for the Debian GNU/Linux distribution, but is not specific to that system. emacsclient works in conjunction with the built-in Emacs server. You can either call emacsclient directly or let other programs run it for you when necessary. On GNU and Unix systems many programs con- sult the environment variable EDITOR (sometimes also VISUAL) to obtain the command used for editing. Thus, setting this environment vari- able to 'emacsclient' will allow these programs to use an already running Emacs for editing. Other operating systems might have their own methods for defining the default editor. For emacsclient to work, you need an already running Emacs with a server. Within Emacs, call the functions `server-start' or `server- mode'. (Your `.emacs' file can do this automatically if you add either `(server-start)' or `(server-mode 1)' to it.) When you've finished editing the buffer, type `C-x #' (`server-edit'). This saves the file and sends a message back to the `emacsclient' program telling it to exit. The programs that use `EDITOR' wait for the "editor" (actually, `emacsclient') to exit. `C-x #' also checks for other pending external requests to edit various files, and selects the next such file. If you set the variable `server-window' to a window or a frame, `C-x #' displays the server buffer in that window or in that frame. OPTIONS
The programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). -nw, -t, --tty open a new Emacs frame on the current terminal -c, --create-frame create a new frame instead of trying to use the current Emacs frame -e, --eval do not visit files but instead evaluate the arguments as Emacs Lisp expressions. -n, --no-wait returns immediately without waiting for you to "finish" the buffer in Emacs. -s, --socket-name=FILENAME use socket named FILENAME for communication. -f, --server-file=FILENAME use TCP configuration file FILENAME for communication. This can also be specified via the `EMACS_SERVER_FILE' environment variable. -a, --alternate-editor=EDITOR if the Emacs server is not running, run the specified editor instead. This can also be specified via the `ALTERNATE_EDITOR' envi- ronment variable. If the value of EDITOR is the empty string, then Emacs is started in daemon mode and emacsclient will try to con- nect to it. -d, --display=DISPLAY tell the server to display the files on the given display. -V, --version print version information and exit -H, --help print this usage information message and exit SEE ALSO
The program is documented fully in Using Emacs as a Server available via the Info system. AUTHOR
This manual page was written by Stephane Bortzmeyer <bortzmeyer@debian.org>, for the Debian GNU/Linux system (but may be used by others). COPYING
This manual page is in the public domain. EMACSCLIENT(1)
All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy