[Solved] New line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] New line
# 1  
Old 02-02-2013
[Solved] New line

in AIX,
Code:
echo "Line1\nLine2", return: 
Line1
Line2

in cygwin,
Code:
echo "Line1\nLine2", returns:
Line1\nLine2

anyone ?

Last edited by radoulov; 02-02-2013 at 04:34 PM.. Reason: Marked as solved.
# 2  
Old 02-02-2013
You have to use -e option to enable interpretation of backslash escapes
Code:
echo -e "Line1\nLine2"

# 3  
Old 02-02-2013
Thank you for a quick reply SIR ! worked perfectly.
# 4  
Old 02-02-2013
Use printf not echo <with some option or other>...

edit: Sorry, forgot to post the link Smilie
echo - The Open Group

Last edited by Scott; 02-02-2013 at 08:50 PM.. Reason: Added link
# 5  
Old 02-02-2013
Like Scott says, printf is to be preferred, and will work on both platforms. The use of echo with command line options is not standard.
Code:
printf "%s\n" "Line1" "Line2"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Output on one line

A simple question, but i am finding it diffcult to find the answer. Can you please tell me how i can get the output of two line on one. I am aware i need to enter \ something, but no sure which charcter, can you advice. CODE for i in `cat LDN_HOSTS_190813 | grep -i LDN | awk '{print... (7 Replies)
Discussion started by: Junes
7 Replies

2. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies

3. UNIX for Dummies Questions & Answers

[Solved] New Line in file

Hi, Though I was successful in following query, I like to know the other ways of doing it. I have a file that is sent as an attachment via mail. However, while opening it, notepad does not recognize new line character whereas other editors like text pad recognizes new line character of unix.... (2 Replies)
Discussion started by: bobbygsk
2 Replies

4. Programming

[SOLVED] C++ print next line until line.empty

Hi, could you please help with the following: I have an input file like: one two three four five six I want to print the lines starting from 'three' to the empty line. Something like that: if ( line == "three" ) { while ( !line.empty() ) { cout <<... (0 Replies)
Discussion started by: apenkov
0 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Help to remove a line from a file

Hi, I just upgraded one my server to latest version RHEL, I have many users who will do SSH from another server. I wanted to update all of the users home directory and remove the security key. For example. /home/XYZ/.ssh/known_hosts and remove this hostsname. Please see below and advise.... (2 Replies)
Discussion started by: samnyc
2 Replies

6. Shell Programming and Scripting

[Solved] Find and append line to output

Hi All, I am trying to write a shell script but not getting desired output. What i am trying to do. 1.I want to use find command command and then use it xargs/exec to append the find output.But i am not getting desired output here is what i am trying to do #find init*.ora -exec `echo... (4 Replies)
Discussion started by: sahil_shine
4 Replies

7. Shell Programming and Scripting

[Solved] making each word of a line to a separate line

Hi, I have a line which has n number of words with separated by space. I wanted to make each word as a separate line. for example, i have a file that has line like i am a good boy i want the output like, i am a good (8 Replies)
Discussion started by: rbalaj16
8 Replies

8. Shell Programming and Scripting

[Solved] Read a .gz file line by line without using gzcat

Hi all Is there a way to read and process a gzip file line by line similar to a text file without using gzcat.. while processing a text file we will usually use the logic exec<sample.txt while read line do echo $line done Is there a similar way to process the gz file in the same... (4 Replies)
Discussion started by: aikhaman
4 Replies

9. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

10. UNIX for Dummies Questions & Answers

solved - removing last n char in every line

Hi all, I want to remove last n char in every line. I'm having the comment as, cnt=10 cat filename | rev | cut -c $cnt- | rev I want to have it with sed or awk or any command except perl. Pls help me in the comment. I have tried few options using sed. But not able to get it. ... (7 Replies)
Discussion started by: poova
7 Replies
Login or Register to Ask a Question