Sponsored Content
Top Forums Shell Programming and Scripting Concatenate strings line by line Post 302267254 by cfajohnson on Friday 12th of December 2008 03:07:30 AM
Old 12-12-2008
Quote:
Originally Posted by hagdanan
Hi, I have a noob question . Can someone help me how to concatenate line by line using this variables?

var1:
Apple|
Banana|

var2:
Red
Yellow

then how can I concatenate both line by line? in which the result would be:
Apple|Red
Banana|Yellow
...
I tried using unix paste but I do not know how to use it if it is a variable.

With bash you can use process substitution:

Code:
var1="Apple|
Banana|"

var2="Red
Yellow"

paste -d '' <( echo "$var1" ) <( echo "$var2" )

:

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to concatenate two command in one line and get the display in one screen

Hi, I would like to know , how to concatenate two command in one line and get the display in one screen for eg command 1 : ls -l /data/logs command 2 : ls -l /data/errors output shd be /data/logs /data/errors xx-xx-xx-xx abc.log xx-xx-xx-xx... (9 Replies)
Discussion started by: vasikaran
9 Replies

2. Shell Programming and Scripting

How to append some strings line by line?

I would like to append the numbers 1, 2, 3, 4 and so on to the lines of the file: Adam Wilkins | Colorado | 36 John Butler | Los Angeles | 47 Cassey Johnson | Minneapolis | 25 Albert Aniston | Miami | 19 .... Tony Legler | Sacramento | 55 Matt Simmons | New York | 38 Output would look... (4 Replies)
Discussion started by: xinoo
4 Replies

3. Shell Programming and Scripting

concatenate all duplicate line in a file.

Hi All, i have a zip file like the format 794051400123|COM|24|0|BD|R|99.98 794051413727|COM|11|0|BD|R|28.99 794051415622|COM|23|0|BD|R|28.99 883929004676|COM|0|0|BD|R|28.99 794051400123|MOM|62|0|BD|R|99.98 794051413727|MOM|4|0|BD|R|28.99 794051415622|MOM|80|0|BD|R|28.99 ... (30 Replies)
Discussion started by: vaskarbasak
30 Replies

4. Shell Programming and Scripting

Logfile - extracting certain lines to concatenate into 1 line

I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run. I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table). Each diagnostic run... (3 Replies)
Discussion started by: BecTech
3 Replies

5. Infrastructure Monitoring

How to concatenate this simple line in Unix?

Hi: I use the snmpget command everyday. And Im getting tire of writing the same line evertime I have to verify something. Example of the line: snmpget -c DreamTeam dal2-hr2 ifAlias.227 The .227 its the circuit interface and also its variable; could be any other number depending on the... (13 Replies)
Discussion started by: javygonx
13 Replies

6. Shell Programming and Scripting

delete repeated strings (tags) in a line and concatenate corresponding words

Hello friends! Each line of my input file has this format: word<TAB>tag1<blankspace>lemma<TAB>tag2<blankspace>lemma ... <TAB>tag3<blankspace>lemma Of this file I need to eliminate all the repeated tags (of the same word) in a line, as in the example here below, but conserving both (all) the... (2 Replies)
Discussion started by: mjomba
2 Replies

7. Shell Programming and Scripting

awk concatenate every line of a file in a single line

I have several hundreds of tiny files which need to be concatenated into one single line and all those in a single file. Some files have several blank lines. Tried to use this script but failed on it. awk 'END { print r } r && !/^/ { print FILENAME, r; r = "" }{ r = r ? r $0 : $0 }' *.txt... (8 Replies)
Discussion started by: sdf
8 Replies

8. Shell Programming and Scripting

Concatenate small line with next line perl script

Hello to all, I'm new to perl, I have input file that contains the string below: 315350535ff450000014534130101ff4500ff45453779ff450ff45545f01ff45ff453245341ff4500000545000This string has as line separator "ff45". So, I want to print each line but the code below is not working. perl -pe '... (2 Replies)
Discussion started by: Ophiuchus
2 Replies

9. Shell Programming and Scripting

Help with concatenate multiple line into one line

Hi, Do anybody experience how to concatenate multiple line into one line by using awk or perl command? Input file: >set1 QAWEQRQ@EWQEASED ASDAEQW QAWEQRQTQ ASRFQWRGWQ From the above Input file, it got 5 lines Desired output file: >set1... (6 Replies)
Discussion started by: perl_beginner
6 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
group(5yp)																group(5yp)

Name
       group - group file in a Yellow Pages environment

Description
       For each group, the file contains:

       Group name
       Encrypted password
       Numerical group ID
       Comma-separated list of all users allowed in the group

       This is an ASCII file.  The fields are separated by colons.  Each group is separated from the next by a new-line.  If the password field is
       null, no password is needed.

       This file resides in the directory.  Because of the encrypted passwords, it can and does have general read permission and can be used,  for
       example, to map numerical group ID's to names.

       A  group file can have a line beginning with a plus (+), which means to incorporate entries from the Yellow Pages.  There are two styles of
       + entries: All by itself, + means to insert the entire contents of the Yellow Pages group file at that point; +name  means  to  insert  the
       entry  (if any) for name from the Yellow Pages at that point.  If a + entry has a password or group member field that is not null, the con-
       tents of that field will override what is contained in the Yellow Pages.  The numerical group ID field cannot be overridden.

Examples
       +myproject:::bill, steve
       +:

       If these entries appear at the end of a group file, then the group myproject will have members bill and steve, and the password	and  group
       ID  of  the  Yellow  Pages entry for the group myproject.  All the groups listed in the Yellow Pages will be pulled in and placed after the
       entry for myproject.

Restrictions
       The command will not change group passwords.

Files
       ULTRIX file system group file

       Yellow Pages group map

See Also
       yppasswd(1yp), setgroups(2), crypt(3), initgroups(3x), passwd(5yp)

																	group(5yp)
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy