LinuxQuestions.org
Review your favorite Linux distribution.
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-24-2013, 12:39 AM   #1
mark_boyer
LQ Newbie
 
Registered: May 2013
Posts: 7

Rep: Reputation: 13
Can someone explain `...' syntax to me?


I've read some things where there is a quoting style like `expression'. The opening quote is the one below the ~ and the closing quote is the one below ". Can someone please give me a term for this and tell me how it works please?
 
Old 05-24-2013, 12:46 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Please show a complete example/quote or give a link; its a bit tricky without seeing it ...
 
Old 05-24-2013, 12:47 AM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,517
Blog Entries: 1

Rep: Reputation: 494Reputation: 494Reputation: 494Reputation: 494Reputation: 494
As a forum writing style? Or as a code element?

`` means to execute the contents between the ``
'' means to not interpret the contents between, so $VARAIBLE is literally the resulting string of characters and not the value of $VARIABLE
"" means to interpret so $VARIABLE would be the contents of the variable.
At least as far as bash syntax goes.

And then there's .. which is the parent directory and . which is the current directory. And other things.
 
1 members found this post helpful.
Old 05-24-2013, 12:58 AM   #4
mark_boyer
LQ Newbie
 
Registered: May 2013
Posts: 7

Original Poster
Rep: Reputation: 13
Maybe just man page style

It's hard to search for punctuation and I don't off hand remember where I saw it. I was thinking it is bash. Maybe it's just the style of man pages.

Here is an excerpt from the AT&T unix grep man page.

The apostrophes ensure the entire expression is evaluated by grep instead
of by the user's shell. The caret `^' matches the null string at the
beginning of a line, and the `\' escapes the `.', which would otherwise
match any character.

To find all lines in a file which do not contain the words `foo' or
`bar':

$ grep -v -e 'foo' -e 'bar' myfile

A simple example of an extended regular expression:

$ egrep '19|20|25' calendar

Peruses the file `calendar' looking for either 19, 20, or 25.


I notice the command line parts use vertical quotes.
 
Old 05-24-2013, 01:13 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
In that case, I assume you're asking about single quotes, not ellipsis (ie ... ) .

Basically, if you enclose a value in double-quotes (" above the 2 key), the shell can process (aka interpolate) that value and replace anything that looks like a varname with the corresponding value; ditto wild card chars like '*'.

If you use single quotes ( ' below the @ symbol on my UK keybd), this protects it from the shell & passes it unchanged to the calling prog eg grep.

If you use back-quotes ( ` on top left key of my keybd) around a string like `blah`, the shell interprets that as a cmd to be run.
NB: backquotes are deprecated; use $(blah) instead.

Read these links for the full info; you really need to grasp this as it'll save you endless stress
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/

HTH
 
1 members found this post helpful.
Old 05-24-2013, 01:27 AM   #6
mark_boyer
LQ Newbie
 
Registered: May 2013
Posts: 7

Original Poster
Rep: Reputation: 13
I was asking about ` opening and ' closing, so that they are not properly matched. After looking through some man pages I had seen recently and my browser history, it seems that this was for a human reader, not the shell. Thank you, though.
 
Old 05-24-2013, 01:45 AM   #7
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Just follow these tutorials:

http://mywiki.wooledge.org/Quotes
http://tldp.org/LDP/abs/html/quoting.html
http://tldp.org/LDP/abs/html/quotingvar.html
http://www.tldp.org/LDP/abs/html/index.html
 
Old 05-24-2013, 02:26 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
@OP: yeah, got to be careful there. Note also that you can't always copy quotes from eg a word processor (think they're sometimes called 'magic quotes'); they end up as ctrl chars iirc...
 
Old 05-24-2013, 01:19 PM   #9
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
In documentation, like man pages, you'll often see ``..'' used as quotation marks. Single versions of the quotes will sometimes be seen too, as the above example shows. These will never be part of any actual code; it's just an old, traditional style of formatting that originated way back the early days of computing.

All shell syntax, at least in the bourne-based shells, will always only use paired symbols (ascii quotes, brackets, parens), sometimes with a prefixing character as well, such as with the $'..' ansi-c quoting pattern.

I can't rule out the possibility of an occasional oddball program that has its own crazy syntax using something like that, however.


PS: While we're on the subject, remember that $(..) is highly recommended over `..`.
 
Old 05-24-2013, 03:35 PM   #10
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 496

Rep: Reputation: 213Reputation: 213Reputation: 213
Quote:
Originally Posted by mark_boyer View Post
I've read some things where there is a quoting style like `expression'. The opening quote is the one below the ~ and the closing quote is the one below ". Can someone please give me a term for this and tell me how it works please?
There's some information in these pages:

http://unix.stackexchange.com/questi...-double-quotes

http://en.wikipedia.org/wiki/Grave_a...in_programming
 
Old 05-24-2013, 05:21 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
It actually depends on where you are reading.

Old man pages (I mean REALLY old, like 1980 vintage), the man pages were designed to be typeset and printed into a reference manual.

The original formatting was defined by "troff", short for "typesetting roff" where "roff" was the original runoff application. troff developed several input styles (tbl for tables, eqn for equations, pic for pictures, toc for table of contents generation, and one for cross reference indexes). These were used by Bell Labs for their document preparation, some of the lost utilities included "style" which would validate documentation as matching the lab standard. These and others were provided in a toolkit called "The Documenters Workbench". Most of auxilary tools disappeared, and the troff utility expanded by having multiple output formats added/generated.

groff which is an extended form of troff can do postscript/pdf - see the manpage for the added utilities available .

One early post formatting tool was "nroff" (for "not troff"). The correct formatting for quotes is to have a left quote (now called the "grave" - http://www.cs.sfu.ca/~ggbaker/reference/characters/), and a right quote (a mirror image). nroff, because it was formatting for a terminal/basic printer, used ascii, which did not have the full quoting - so it substituted an apostrophe (') for the closing typesetting quote (the mirror image of a grave). Thus the odd appearance in some documentation.

What made it worse was adding the backtic and apostrophe for shell programming. In troff these are drastically different characters than used for quoting, and usage is plain. In nroff, they are not clear, and it gets confusing when the formatting uses plain ascii.

ON to the next confusing part...

The original man utility itself, was just a short shell script - basically just one line, the series of pipe commands to tie the various preformatters (the ones handling tables, pictures, and such) together with either troff or nroff. If it was sent to nroff, then the output was piped to more. Later changes (when disk space was available) system installation would preformat the man pages into ascii so that "man" only needed to become "more <manpath>/<section>/<page>" or the piped form if the page didn't exist already formatted. Formatting this way was nice - as it eliminated the rather CPU bound formatters... but it also meant that if you were printing you got the plain ascii... with the not so nice formatting.

troff, the preprocessors, and the macros defining the text all predated TeX, but produced high quality output. A large number of UNIX textbooks were written using it for the formatter. Most of the current Linux books still follow the style laid down by Bell Labs, though they may not use troff anymore.
 
3 members found this post helpful.
Old 05-24-2013, 05:53 PM   #12
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 496

Rep: Reputation: 213Reputation: 213Reputation: 213
Thanks for that information jpollard. Then, would it be correct to say that the `...' syntax used today by TeX, Texinfo and groff is inherited from the original Unix utilities nroff/troff?
 
Old 05-24-2013, 07:22 PM   #13
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
TeX is totally separate. It was specifically developed for formatting mathematics.

Texinfo and groff do inherit - especially groff. Texinfo is not directly related, only the resulting format is similar due to it using ascii for output: http://www.gnu.org/software/texinfo/

I believe the man pages can still be processed by groff, most of the equations/diagrams are no longer used, so try a "zcat /usr/share/man1/<somthing.1.gz> groff -X -man -". Note, some things might be missing, (gxditview for instance) for that to work. If it doesn't you can use "groff -man -", dropping the -X and redirect the output to a file as it will be postscript. You can use a postscript viewer to look at it; or just print it.

The first UNIX system I got my hands on (UNIX v6) had the man pages on it.. so I printed them. For about a year that was my UNIX reference.
 
  


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
[SOLVED] Explain the awk syntax shivaa Linux - Newbie 2 10-20-2012 11:45 AM
Can anyone explain what program language uses this syntax? pr&int martinwprior Programming 3 05-07-2008 04:44 AM
Can someone explain this syntax please? stefaandk Linux - General 1 09-27-2006 09:27 AM
Please help to explain the syntax for 'update-alternatives' davidas Linux - Newbie 1 04-11-2004 07:22 AM


All times are GMT -5. The time now is 10:22 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