12-09-2008
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
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
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
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
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
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
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
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
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
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
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
line(1) General Commands Manual line(1)
NAME
line - read one line from user input
SYNOPSIS
timeout]
DESCRIPTION
copies one line (up to a new-line) from the standard input and writes it on the standard output. It returns an exit code of 1 on EOF and
always prints at least a new-line. It is often used within shell files to read from the user's terminal.
Options
recognizes the following command-line option:
Timeout after
timeout seconds where timeout is an integer value (if a non-integer value is specified, it is converted to an integer;
i.e., rounded down). A blank is required between and the timeout argument. This option is not documented in POSIX and
other industry standards, and should not be used in portable applications.
EXTERNAL INFLUENCES
International Code Set Support
Single- and multi-byte character code sets are supported.
EXAMPLES
The following lines in a shell script prompt for a file name and display information about the file:
To limit the response time to 10 seconds, use the form:
then test for no response. If no response occurs before timeout expires, a default behavior should be provided.
WARNINGS
This command is likely to be withdrawn from X/Open standards. Applications using this command might not be portable to other vendors' sys-
tems. As an alternative is recommended.
SEE ALSO
sh(1), read(2).
STANDARDS CONFORMANCE
line(1)