Concatenate strings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Concatenate strings
# 15  
Old 08-06-2014
<^M> is the carriage return (<CR>, 0x0D) char, and it does exactly that: it prints DB34 from your sample, then goes back to the first position in the line, and prints @example.com, overwriting the DB34.
This is frequently the problem when people work between windows and *nix environments; all DOS/windows systems use <CR><LF> line terminators while *nix use just <LF>.
# 16  
Old 08-06-2014
Thanks for the response RudiC. Is there any other option with
Code:
tr -d '\r'

which could avoid carriage return problem?

---------- Post updated at 09:50 PM ---------- Previous update was at 09:47 PM ----------

And i didn't understand why did the linux system which i logged on remotely using putty, consider f1.txt which is inputfile in DOS format?
# 17  
Old 08-06-2014
Use *nix compatible editors in the first place. If not possible, convert file with e.g. dos2unix, or recode / iconv. awk also can remove the \r.
# 18  
Old 08-09-2014
Hi RudiC, i tried with dos2unix command which is available in my linux server. but didn't get expected result in the f2.txt o/p file
Code:
[linux1@XXXXXXX yyyyyy]$ dos2unix f1.txt
dos2unix: converting file f1.txt to UNIX format ...

# 19  
Old 08-09-2014
Saying "didn't get the expected result" gives us zero useful information.

What did you get?
What did you expect?
Show us the output of the commands:
Code:
od -c your_current_script
           and
od -c /home/linux1/xxxxxxx/f1.txt

and then run your_current_script and show us any output it printed and the output of the command:
Code:
od -c /home/linux1/xxxxxxx/f2.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Concatenate strings in a a for loop

hi guys, I have this question. I am creating an script to that read a text file(.ini) with the list of the patterns to find for example: EPMS_VO EMPS_PARTS Then it check if file have been delivered in a folder and process it with each pattern, but I am having problems concatenting the... (7 Replies)
Discussion started by: Danman
7 Replies

2. Programming

Concatenate two strings

Hello! Can anyone explain line 28 for me? I was thinking *a would be replaced by *b, but it actually appends *a to *b. I know it is related to pointer address, but could not figure it out by myself. Thanks a lot! 1 //Concatenate two strings 2 3 #include<stdio.h> 4 char *stradd (char *,... (5 Replies)
Discussion started by: yifangt
5 Replies

3. Shell Programming and Scripting

Concatenate text between patterns in individual strings

In any given file, wherever a certain data block exists I need to concatenate the values(text after each "=" sign) from that block. in that block. The block starts and ends with specific pattern, say BEGIN DS and END DS respectively. The block size may vary. A file will have multiple such blocks.... (12 Replies)
Discussion started by: Prev
12 Replies

4. Web Development

Concatenate Strings

hi..:) this is my sample part of my program.. $csv_output .= $row.",". $row.",". $row.",". $row.",". $row.",". ... (2 Replies)
Discussion started by: Jeneca
2 Replies

5. UNIX for Dummies Questions & Answers

concatenate strings

if i use echo "ravi" echo "sankar" it showing output ravi sankar but i want output as ravi sankar remember sankar should be in another echo statement only (2 Replies)
Discussion started by: shankr3
2 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. UNIX for Dummies Questions & Answers

Concatenate Strings

Hi Friends, I have a requirement I need to concatenate the below two strings. String 1 = /@jobid_at_ String 2 = value stored in ORACLE_SID String 3 = string1 concatenated with String 2. Please let me know how should i do it in UNIX. Thanks, (2 Replies)
Discussion started by: diva_thilak
2 Replies

8. Shell Programming and Scripting

How to concatenate two strings or several strings into one string in B-shell?

like connect "summer" and "winter" to "summerwinter"? Can anybody help me? thanks a lot. (2 Replies)
Discussion started by: fontana
2 Replies
Login or Register to Ask a Question