LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-31-2011, 08:15 AM   #1
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
shell code


Hi all

I've got a question about this piece of code

Code:
exec "$JAVA" \
    $JAVA_OPTS \
    -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
    -Dprogram.name="$PROGNAME" \
    -classpath $JBOSS_CLASSPATH \
    org.jboss.console.twiddle.Twiddle "$@"
is this possible? I mean with the "\" ??
can someone explain what's happening here?

Thanks in advance

Brownie
 
Old 05-31-2011, 08:25 AM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,608

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
The '\' at the end simply indicate that all these lines are to be interpreted as one single line.
Does this answer your question?
 
1 members found this post helpful.
Old 05-31-2011, 08:42 AM   #3
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Original Poster
Rep: Reputation: 12
okay, thanks ^^
i didn't know that was possible

 
Old 05-31-2011, 08:52 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
I would add that the backslash should be the very last character in the line, otherwise it is interpreted as an escape character. If you have a backslash followed by a blank space, it will escape the blank and the shell terminates the input thereafter. Example:
Code:
$ echo hello \
> world
hello world
$ echo hello \ <--- here I put a blank space
hello  
$
 
2 members found this post helpful.
Old 05-31-2011, 08:52 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
To be more precise, \ escapes the character following it, which has the effect of telling the shell to ignore normally shell-reserved characters and treating them as literal.

In this case the character being escaped is the non-printing newline character (ascii 0x0A ). Normally the shell interprets it as the end of a command, but escaping it makes it just a plain old newline, which the shell treats as regular whitespace.

It's a commonly used technique for breaking long commands up onto separate lines for readability.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell code help please themanwhowas Linux - General 5 09-18-2009 05:12 AM
help to explain the shell code ! nillgump Linux From Scratch 1 10-11-2008 12:09 PM
Semaphore-like shell code omnio Programming 13 03-12-2007 04:36 AM
Shell source code drimades Linux - General 6 10-24-2006 11:52 AM
shell scource code??? akshay_jp Linux - General 3 11-05-2005 10:46 PM


All times are GMT -5. The time now is 01:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration