Sponsored Content
Top Forums Shell Programming and Scripting Concatenate strings line by line Post 302266053 by hagdanan on Tuesday 9th of December 2008 09:37:51 AM
Old 12-09-2008
Data Concatenate strings line by line

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

just to generate a row result i was using:

var1=$(
cat <<-__EOF__
APPLE
BANANA
__EOF__
)

var2=$(
cat <<-__EOF__
RED
YELLOW
__EOF__
)

I tried using unix paste but I do not know how to use it if it is a variable.


Thanks for your help.
 

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
function::ansi_set_color3

FUNCTION:(3stap)					  Utility functions for using an					  FUNCTION:(3stap)

NAME
function::ansi_set_color3 - Set the ansi Select Graphic Rendition mode. SYNOPSIS
ansi_set_color3(fg:long,bg:long,attr:long) ARGUMENTS
fg Foreground color to set. bg Background color to set. attr Color attribute to set. DESCRIPTION
Sends ansi code for Select Graphic Rendition mode for the given forground color, Black(30), Blue(34), Green(32), Cyan(36), Red(31), Purple(35), Brown(33), Light Gray(37), the given background color, Black(40), Red(41), Green(42), Yellow(43), Blue(44), Magenta(45), Cyan(46), White(47) and the color attribute All attributes off(0), Intensity Bold(1), Underline Single(4), Blink Slow(5), Blink Rapid(6), Image Negative(7). SystemTap Tapset Reference May 2013 FUNCTION:(3stap)
All times are GMT -4. The time now is 02:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy