Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I often use the space-backslash combination ( ) to split a command and its parameters into various lines and make it more readable:

/home/user> ls -ltra \
> file1.txt \
> file2.txt

Recently I used an instruction with a similar format on my terminal window. Since I was going use the same files in various instructions, I decided to highlight\copy the whole command with my mouse and paste them in an open editor.
Unfortunately,

  1. I only highlighted with my mouse the two file lines and
  2. pasted them by mistake into the same terminal window:

Like this:

/home/user> > /home/user/file1.txt
> > /home/user/file2.txt

They system thought I was overwritting the files. The data was lost. Fortunately, there was backup!

Now my question:

Can a terminal session be re-configured so it uses a symbol, other than the > sign, at the start of a split command? Something which won't have such horrendous consequences.

Example:

/home/user> ls -ltra \
# file1.txt \
# file2.txt

UPDATE

I am using Korn shell (/usr/bin/ksh) on a Solaris server. Korn is the company's default shell.

share|improve this question
    
Just tried changing the PS2 variable to '# ' and it works in Korn. Thank you for the information. –  lamcro Jul 11 at 19:30

3 Answers 3

up vote 3 down vote accepted

If you're using a sh-compatible shell (like bash), that > prompt is called the "secondary prompt". It's set by the value of the PS2 variable, just like PS1 sets the normal prompt.

You should be able to change it to # pretty easily:

PS2='# '

You might want to put that into your ~/.bashrc (or whatever the equivalent is for whatever shell you're using).

share|improve this answer

It's not based on "the system". It's based on your shell.

In bash or other Bourne shells

   PS2    The  value of this parameter is expanded as with PS1 and used as
          the secondary prompt string.  The default is ``> ''.
share|improve this answer

-You try use this way!...

/home/user> ls -ltra \\ file1.txt \\file2.txt ...

This way you can get a better result! and another question what kind terminal you are using, bash, sh, csh ?...

share|improve this answer
    
The point of the question was to type a multiline command, using backslash+newline as a line continuation. Not to have backslash in the command, with or without a space after it. –  Gilles Jul 11 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.