LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   New lines in terminal (https://www.linuxquestions.org/questions/linux-newbie-8/new-lines-in-terminal-608190/)

mg92865 12-20-2007 02:11 PM

New lines in terminal
 
I am learning to use dar from the command line. My dar command is 3 lines long full width of the monitor. Is there a character sequence to insert between commands so that my 3 lines can be broken into more lines? A simple return causes the command not to run.

I searched on line length, man terminal, but was unable to locate what I am looking for.

What I have (example):

-X "*.*.dar" -X "*.jpg" --create /darbu -s 650M -y -v -Z "*.mp3" -Z "*.avi" -Z "*.mpg" -Z "*.mpeg" -Z "*.divx" -Z "*.rm" -Z "*.wmv" -Z "*.wma" -Z "*.asf" -Z "*.ra" -Z "*.gif" -Z "*.jpg" -Z "*.jpeg" -Z "*.png" -Z "*.zip" -Z "*.tgz" -Z "*.gzip" -Z "*.bzip" -Z "*.bzip2" -Z "*.rar" -Z "*.Z" --fs-root / -g home/mike/Desktop/autodealer --prune home/mike/tmp

What I would like:

-X "*.*.dar" -X "*.jpg" --create /darbu -s 650M -y -v
-Z "*.mp3" -Z "*.avi" -Z "*.mpg" -Z "*.mpeg" -Z "*.divx" -Z "*.rm"
-Z "*.wmv" -Z "*.wma" -Z "*.asf" -Z "*.ra" -Z "*.gif" -Z "*.jpg"
-Z "*.jpeg" -Z "*.png" -Z "*.zip" -Z "*.tgz" -Z "*.gzip" -Z "*.bzip"
-Z "*.bzip2" -Z "*.rar" -Z "*.Z"
--fs-root /
-g home/mike/Desktop/autodealer
--prune home/mike/tmp

But there needs to be a break of some type at the end of each line, and it cannot be a carriage return. Any suggestions on search topics?

mg92865

b0uncer 12-20-2007 02:13 PM

Tried '\' already?

matthewg42 12-20-2007 02:43 PM

If you put a backslash \ at the end of the line (with no spaces after it), tyu can continue to enter a command on a new line,. e.g.
Code:

echo this is a long command which has \
been split over more than one line


mg92865 12-21-2007 06:15 AM

The added \ solved the problem
 
Hello,

Thank you for the prompt response. Adding the \ solves my
problem.

I have not seen this. I looked for a man terminal page but none
exists on my system. What would I have searched on to find
more on the terminal or the use of "\" in terminal.

Thanks,

mg92865

fakie_flip 10-28-2012 06:44 AM

Quote:

Originally Posted by matthewg42 (Post 2997349)
If you put a backslash \ at the end of the line (with no spaces after it), tyu can continue to enter a command on a new line,. e.g.
Code:

echo this is a long command which has \
been split over more than one line


How do you insert a newline into the terminal without putting it in a script or copy and paste?

Snark1994 10-28-2012 07:44 AM

Quote:

Originally Posted by fakie_flip (Post 4816651)
How do you insert a newline into the terminal without putting it in a script or copy and paste?

Like this:

Code:

echo -e "foo bah\nbaz"
The '-e' flag tells echo to expand newlines, among other things.

David the H. 10-28-2012 05:58 PM

Quote:

Originally Posted by mg92865 (Post 2997973)
I looked for a man terminal page but none
exists on my system.

This is not a "terminal" question, it's a shell syntax one. You need to look in your bash man page, or whatever other shell you use as the default.

Here are a few useful bash references for you:
http://mywiki.wooledge.org/BashGuide
http://wiki.bash-hackers.org/start
http://www.linuxcommand.org/index.php
http://wiki.bash-hackers.org/scripting/newbie_traps
http://mywiki.wooledge.org/BashPitfalls
http://mywiki.wooledge.org/BashFAQ
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/index.html
http://www.gnu.org/software/bash/manual/bashref.html
http://ss64.com/bash/

fakie_flip 10-29-2012 03:24 AM

Quote:

Originally Posted by Snark1994 (Post 4816682)
Like this:

Code:

echo -e "foo bah\nbaz"
The '-e' flag tells echo to expand newlines, among other things.

No, in the command, not the output.

Quote:

echo this is a long command which has \
been split over more than one line

chrism01 10-29-2012 05:00 AM

I'm not entirely clear what you're asking here, but as above, the syntax of *nix shells is such that a newline is assumed to be the end of a cmd UNLESS you append a '\' at the physical end of the line.

You can print out '\n' if you want to see a new line, and echo can explicitly insert a newline as above or append (-n) instead of (default) putting a newline
eg
Code:

echo -en "foo bah\nbaz"
foo bah


ntubski 10-29-2012 05:09 AM

Quote:

Originally Posted by fakie_flip (Post 4816651)
How do you insert a newline into the terminal without putting it in a script or copy and paste?

Press enter, if the shell knows that command isn't finished (because of a backslash or unclosed quote) it will prompt for more input after the newline:
Code:

~/tmp$ echo this is a long command which has \
> been split over more than one line
this is a long command which has been split over more than one line

You can see on the second line the prompt is ">", the value of $PS2.

fakie_flip 10-29-2012 11:56 PM

Thank you ntubski. That's what I was looking for.


All times are GMT -5. The time now is 04:03 PM.