How does â$â work in âapt-cache search something$â

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I understand that:
$ apt-cache search package_name
will search for matches in names and descriptions.
But how does this work?
$ apt-cache search package_name$
For example,
$ apt-cache search desktop
will produce a list of names and short descriptions of packages that have "desktop" anywhere in the name or description.
Then, if I understand correctly,
$ apt-cache search desktop$
should produce a subset in which "desktop" is the last word either in the name or in any line in the description.
But I found one example, xjig, which shows up with apt-cache search desktop but doesn't show up with apt-cache search desktop$ even though the description according to apt-cache show xjig has "desktop" in the second-last line of the description:
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
So why is xjig not included in the output of apt-cache search desktop$?
apt regular-expression
add a comment |Â
up vote
3
down vote
favorite
I understand that:
$ apt-cache search package_name
will search for matches in names and descriptions.
But how does this work?
$ apt-cache search package_name$
For example,
$ apt-cache search desktop
will produce a list of names and short descriptions of packages that have "desktop" anywhere in the name or description.
Then, if I understand correctly,
$ apt-cache search desktop$
should produce a subset in which "desktop" is the last word either in the name or in any line in the description.
But I found one example, xjig, which shows up with apt-cache search desktop but doesn't show up with apt-cache search desktop$ even though the description according to apt-cache show xjig has "desktop" in the second-last line of the description:
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
So why is xjig not included in the output of apt-cache search desktop$?
apt regular-expression
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I understand that:
$ apt-cache search package_name
will search for matches in names and descriptions.
But how does this work?
$ apt-cache search package_name$
For example,
$ apt-cache search desktop
will produce a list of names and short descriptions of packages that have "desktop" anywhere in the name or description.
Then, if I understand correctly,
$ apt-cache search desktop$
should produce a subset in which "desktop" is the last word either in the name or in any line in the description.
But I found one example, xjig, which shows up with apt-cache search desktop but doesn't show up with apt-cache search desktop$ even though the description according to apt-cache show xjig has "desktop" in the second-last line of the description:
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
So why is xjig not included in the output of apt-cache search desktop$?
apt regular-expression
I understand that:
$ apt-cache search package_name
will search for matches in names and descriptions.
But how does this work?
$ apt-cache search package_name$
For example,
$ apt-cache search desktop
will produce a list of names and short descriptions of packages that have "desktop" anywhere in the name or description.
Then, if I understand correctly,
$ apt-cache search desktop$
should produce a subset in which "desktop" is the last word either in the name or in any line in the description.
But I found one example, xjig, which shows up with apt-cache search desktop but doesn't show up with apt-cache search desktop$ even though the description according to apt-cache show xjig has "desktop" in the second-last line of the description:
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
So why is xjig not included in the output of apt-cache search desktop$?
apt regular-expression
apt regular-expression
edited 5 mins ago
GAD3R
23.6k164899
23.6k164899
asked Jan 28 '14 at 6:02
user15760
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
From the apt-cache man page:
search regex...
search performs a full text search on all available package lists for the
POSIX regex pattern given, see regex(7). It searches the package names
and the descriptions for an occurrence of the regular expression and
prints out the package name and the short description, including virtual
package names. If --full is given then output identical to show is
produced for each matched package, and if --names-only is given then the
long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that
are and'ed together.
Notice it states regex(7). So when you tell apt-cache to search for something you're providing it a regular expression. The $ in a regex means that you want to match, anchored to the end of strings.
So if we're gave the value desktop$ we'd only match strings where desktop was at the end of strings such as:
- this is a desktop
- this is a very long string with desktop
But it wouldn't match strings such as:
- this is desktop in the window
- this is another desktop in the window
In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value.
Example
Here's xjig's description.
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
If I search for all strings that end with xjig .$.
$ apt-cache search 'xjig .$'
xjig - An X11 jigsaw puzzle
Remember that the value for the description is just a long string that is wrapped at that point, so though "desktop" is at the end a line, it isn't actually at the end of the description's value.
Alternative
Given you're looking for the word desktop you could look for the string with either spaces on either side (s), or word boundaries (b).
$ apt-cache search 'sdesktops' | grep xjig
xjig - An X11 jigsaw puzzle
$ apt-cache search 'bdesktopb' | grep xjig
xjig - An X11 jigsaw puzzle
Understanding regex anchors
Perhaps using grep to see what an anchor does in a regex would help.
desktop not at the end
$ echo "this is a desktop string" | grep "desktop$"
$
desktop at the end
$ echo "this is a desktop" | grep "desktop$"
this is a desktop
The compliment to $ for anchoring matches to the end of strings, is the ^ for anchoring matches to the beginning.
desktop not at beginning
$ echo "this is a desktop" | grep "^desktop"
$
desktop at beginning
$ echo "desktop this is a desktop" | grep "^desktop"
desktop this is a desktop
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you giveapt-cache search xjig .$as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?
â user15760
Jan 28 '14 at 7:16
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments toapt-cache searchin single quotes, so it's a single argument we're looking for.
â slmâ¦
Jan 28 '14 at 7:19
Okay, but why the space afterxjigand before the period?
â user15760
Jan 28 '14 at 7:27
1
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run thisapt-cache show xjigand look at how the Description field shows up.
â slmâ¦
Jan 28 '14 at 7:29
add a comment |Â
up vote
3
down vote
The description field is a multi-line field but $ in the regexp, means the end of the field, not the end of each line of the field. So, if you want to search for desktop at the end of a line or at the end of the field, you need:
apt-cache search 'desktop(
|$)'
Or with the ksh93 $'...' quotes (also found in zsh and bash) allowing x escape sequences:
apt-cache search $'desktop(n|$)'
Also note that . does match a newline character. Written in perl, that would be:
print "$name - $summary" if
$name =~ qr$resi ||
$description =~ qr$resi;
(except they are not perl regexps of course)
You might want to explain the$''notation. Most ppl are not familiar with it.
â slmâ¦
Jan 28 '14 at 7:22
Yes, I was about to ask that becauseapt-cache search 'desktop(n|$)'apparently works as well.
â user15760
Jan 28 '14 at 7:24
@vasa1. Hmmm. Weird,'desktop(n|$)'seems to work indeed, but not'desktopn'nor'desktop(n)'. I don't know why.
â Stéphane Chazelas
Jan 28 '14 at 7:27
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with thebapproach.
â slmâ¦
Jan 28 '14 at 7:32
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
From the apt-cache man page:
search regex...
search performs a full text search on all available package lists for the
POSIX regex pattern given, see regex(7). It searches the package names
and the descriptions for an occurrence of the regular expression and
prints out the package name and the short description, including virtual
package names. If --full is given then output identical to show is
produced for each matched package, and if --names-only is given then the
long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that
are and'ed together.
Notice it states regex(7). So when you tell apt-cache to search for something you're providing it a regular expression. The $ in a regex means that you want to match, anchored to the end of strings.
So if we're gave the value desktop$ we'd only match strings where desktop was at the end of strings such as:
- this is a desktop
- this is a very long string with desktop
But it wouldn't match strings such as:
- this is desktop in the window
- this is another desktop in the window
In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value.
Example
Here's xjig's description.
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
If I search for all strings that end with xjig .$.
$ apt-cache search 'xjig .$'
xjig - An X11 jigsaw puzzle
Remember that the value for the description is just a long string that is wrapped at that point, so though "desktop" is at the end a line, it isn't actually at the end of the description's value.
Alternative
Given you're looking for the word desktop you could look for the string with either spaces on either side (s), or word boundaries (b).
$ apt-cache search 'sdesktops' | grep xjig
xjig - An X11 jigsaw puzzle
$ apt-cache search 'bdesktopb' | grep xjig
xjig - An X11 jigsaw puzzle
Understanding regex anchors
Perhaps using grep to see what an anchor does in a regex would help.
desktop not at the end
$ echo "this is a desktop string" | grep "desktop$"
$
desktop at the end
$ echo "this is a desktop" | grep "desktop$"
this is a desktop
The compliment to $ for anchoring matches to the end of strings, is the ^ for anchoring matches to the beginning.
desktop not at beginning
$ echo "this is a desktop" | grep "^desktop"
$
desktop at beginning
$ echo "desktop this is a desktop" | grep "^desktop"
desktop this is a desktop
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you giveapt-cache search xjig .$as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?
â user15760
Jan 28 '14 at 7:16
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments toapt-cache searchin single quotes, so it's a single argument we're looking for.
â slmâ¦
Jan 28 '14 at 7:19
Okay, but why the space afterxjigand before the period?
â user15760
Jan 28 '14 at 7:27
1
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run thisapt-cache show xjigand look at how the Description field shows up.
â slmâ¦
Jan 28 '14 at 7:29
add a comment |Â
up vote
3
down vote
accepted
From the apt-cache man page:
search regex...
search performs a full text search on all available package lists for the
POSIX regex pattern given, see regex(7). It searches the package names
and the descriptions for an occurrence of the regular expression and
prints out the package name and the short description, including virtual
package names. If --full is given then output identical to show is
produced for each matched package, and if --names-only is given then the
long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that
are and'ed together.
Notice it states regex(7). So when you tell apt-cache to search for something you're providing it a regular expression. The $ in a regex means that you want to match, anchored to the end of strings.
So if we're gave the value desktop$ we'd only match strings where desktop was at the end of strings such as:
- this is a desktop
- this is a very long string with desktop
But it wouldn't match strings such as:
- this is desktop in the window
- this is another desktop in the window
In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value.
Example
Here's xjig's description.
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
If I search for all strings that end with xjig .$.
$ apt-cache search 'xjig .$'
xjig - An X11 jigsaw puzzle
Remember that the value for the description is just a long string that is wrapped at that point, so though "desktop" is at the end a line, it isn't actually at the end of the description's value.
Alternative
Given you're looking for the word desktop you could look for the string with either spaces on either side (s), or word boundaries (b).
$ apt-cache search 'sdesktops' | grep xjig
xjig - An X11 jigsaw puzzle
$ apt-cache search 'bdesktopb' | grep xjig
xjig - An X11 jigsaw puzzle
Understanding regex anchors
Perhaps using grep to see what an anchor does in a regex would help.
desktop not at the end
$ echo "this is a desktop string" | grep "desktop$"
$
desktop at the end
$ echo "this is a desktop" | grep "desktop$"
this is a desktop
The compliment to $ for anchoring matches to the end of strings, is the ^ for anchoring matches to the beginning.
desktop not at beginning
$ echo "this is a desktop" | grep "^desktop"
$
desktop at beginning
$ echo "desktop this is a desktop" | grep "^desktop"
desktop this is a desktop
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you giveapt-cache search xjig .$as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?
â user15760
Jan 28 '14 at 7:16
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments toapt-cache searchin single quotes, so it's a single argument we're looking for.
â slmâ¦
Jan 28 '14 at 7:19
Okay, but why the space afterxjigand before the period?
â user15760
Jan 28 '14 at 7:27
1
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run thisapt-cache show xjigand look at how the Description field shows up.
â slmâ¦
Jan 28 '14 at 7:29
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
From the apt-cache man page:
search regex...
search performs a full text search on all available package lists for the
POSIX regex pattern given, see regex(7). It searches the package names
and the descriptions for an occurrence of the regular expression and
prints out the package name and the short description, including virtual
package names. If --full is given then output identical to show is
produced for each matched package, and if --names-only is given then the
long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that
are and'ed together.
Notice it states regex(7). So when you tell apt-cache to search for something you're providing it a regular expression. The $ in a regex means that you want to match, anchored to the end of strings.
So if we're gave the value desktop$ we'd only match strings where desktop was at the end of strings such as:
- this is a desktop
- this is a very long string with desktop
But it wouldn't match strings such as:
- this is desktop in the window
- this is another desktop in the window
In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value.
Example
Here's xjig's description.
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
If I search for all strings that end with xjig .$.
$ apt-cache search 'xjig .$'
xjig - An X11 jigsaw puzzle
Remember that the value for the description is just a long string that is wrapped at that point, so though "desktop" is at the end a line, it isn't actually at the end of the description's value.
Alternative
Given you're looking for the word desktop you could look for the string with either spaces on either side (s), or word boundaries (b).
$ apt-cache search 'sdesktops' | grep xjig
xjig - An X11 jigsaw puzzle
$ apt-cache search 'bdesktopb' | grep xjig
xjig - An X11 jigsaw puzzle
Understanding regex anchors
Perhaps using grep to see what an anchor does in a regex would help.
desktop not at the end
$ echo "this is a desktop string" | grep "desktop$"
$
desktop at the end
$ echo "this is a desktop" | grep "desktop$"
this is a desktop
The compliment to $ for anchoring matches to the end of strings, is the ^ for anchoring matches to the beginning.
desktop not at beginning
$ echo "this is a desktop" | grep "^desktop"
$
desktop at beginning
$ echo "desktop this is a desktop" | grep "^desktop"
desktop this is a desktop
From the apt-cache man page:
search regex...
search performs a full text search on all available package lists for the
POSIX regex pattern given, see regex(7). It searches the package names
and the descriptions for an occurrence of the regular expression and
prints out the package name and the short description, including virtual
package names. If --full is given then output identical to show is
produced for each matched package, and if --names-only is given then the
long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that
are and'ed together.
Notice it states regex(7). So when you tell apt-cache to search for something you're providing it a regular expression. The $ in a regex means that you want to match, anchored to the end of strings.
So if we're gave the value desktop$ we'd only match strings where desktop was at the end of strings such as:
- this is a desktop
- this is a very long string with desktop
But it wouldn't match strings such as:
- this is desktop in the window
- this is another desktop in the window
In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value.
Example
Here's xjig's description.
Description-en: An X11 jigsaw puzzle
xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut
into pieces. The goal (as with any jigsaw puzzle) is to reassemble the
original picture.
.
Tiles may be freely rotated by use of the mouse, flipped (for
double-sided puzzles) and even shown as shaped windows on the desktop
(fast machine/video card recommended for the latter!). An example image
is provided in /usr/share/games/xjig .
If I search for all strings that end with xjig .$.
$ apt-cache search 'xjig .$'
xjig - An X11 jigsaw puzzle
Remember that the value for the description is just a long string that is wrapped at that point, so though "desktop" is at the end a line, it isn't actually at the end of the description's value.
Alternative
Given you're looking for the word desktop you could look for the string with either spaces on either side (s), or word boundaries (b).
$ apt-cache search 'sdesktops' | grep xjig
xjig - An X11 jigsaw puzzle
$ apt-cache search 'bdesktopb' | grep xjig
xjig - An X11 jigsaw puzzle
Understanding regex anchors
Perhaps using grep to see what an anchor does in a regex would help.
desktop not at the end
$ echo "this is a desktop string" | grep "desktop$"
$
desktop at the end
$ echo "this is a desktop" | grep "desktop$"
this is a desktop
The compliment to $ for anchoring matches to the end of strings, is the ^ for anchoring matches to the beginning.
desktop not at beginning
$ echo "this is a desktop" | grep "^desktop"
$
desktop at beginning
$ echo "desktop this is a desktop" | grep "^desktop"
desktop this is a desktop
edited Jan 28 '14 at 7:29
answered Jan 28 '14 at 7:02
slmâ¦
241k66501669
241k66501669
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you giveapt-cache search xjig .$as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?
â user15760
Jan 28 '14 at 7:16
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments toapt-cache searchin single quotes, so it's a single argument we're looking for.
â slmâ¦
Jan 28 '14 at 7:19
Okay, but why the space afterxjigand before the period?
â user15760
Jan 28 '14 at 7:27
1
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run thisapt-cache show xjigand look at how the Description field shows up.
â slmâ¦
Jan 28 '14 at 7:29
add a comment |Â
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you giveapt-cache search xjig .$as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?
â user15760
Jan 28 '14 at 7:16
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments toapt-cache searchin single quotes, so it's a single argument we're looking for.
â slmâ¦
Jan 28 '14 at 7:19
Okay, but why the space afterxjigand before the period?
â user15760
Jan 28 '14 at 7:27
1
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run thisapt-cache show xjigand look at how the Description field shows up.
â slmâ¦
Jan 28 '14 at 7:29
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you give
apt-cache search xjig .$ as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?â user15760
Jan 28 '14 at 7:16
I am able to understand "In your case the string desktop in xjig's description, though at the end of a line in the description, is not at the end of the description field's value." I think that would explain my confusion. But why did you give
apt-cache search xjig .$ as an example? That has me confused again. Doesn't it mean we're now searching for two terms, xjig and .$?â user15760
Jan 28 '14 at 7:16
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments to
apt-cache search in single quotes, so it's a single argument we're looking for.â slmâ¦
Jan 28 '14 at 7:19
@vasa1 - no we're looking for a string "xjig ." but only ones that are at the end of the strings we're attempting to match. Remember we're quoting the arguments to
apt-cache search in single quotes, so it's a single argument we're looking for.â slmâ¦
Jan 28 '14 at 7:19
Okay, but why the space after
xjigand before the period?â user15760
Jan 28 '14 at 7:27
Okay, but why the space after
xjigand before the period?â user15760
Jan 28 '14 at 7:27
1
1
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run this
apt-cache show xjig and look at how the Description field shows up.â slmâ¦
Jan 28 '14 at 7:29
@vasa1 - that's how the description shows up for xjig. No other reason than that. Run this
apt-cache show xjig and look at how the Description field shows up.â slmâ¦
Jan 28 '14 at 7:29
add a comment |Â
up vote
3
down vote
The description field is a multi-line field but $ in the regexp, means the end of the field, not the end of each line of the field. So, if you want to search for desktop at the end of a line or at the end of the field, you need:
apt-cache search 'desktop(
|$)'
Or with the ksh93 $'...' quotes (also found in zsh and bash) allowing x escape sequences:
apt-cache search $'desktop(n|$)'
Also note that . does match a newline character. Written in perl, that would be:
print "$name - $summary" if
$name =~ qr$resi ||
$description =~ qr$resi;
(except they are not perl regexps of course)
You might want to explain the$''notation. Most ppl are not familiar with it.
â slmâ¦
Jan 28 '14 at 7:22
Yes, I was about to ask that becauseapt-cache search 'desktop(n|$)'apparently works as well.
â user15760
Jan 28 '14 at 7:24
@vasa1. Hmmm. Weird,'desktop(n|$)'seems to work indeed, but not'desktopn'nor'desktop(n)'. I don't know why.
â Stéphane Chazelas
Jan 28 '14 at 7:27
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with thebapproach.
â slmâ¦
Jan 28 '14 at 7:32
add a comment |Â
up vote
3
down vote
The description field is a multi-line field but $ in the regexp, means the end of the field, not the end of each line of the field. So, if you want to search for desktop at the end of a line or at the end of the field, you need:
apt-cache search 'desktop(
|$)'
Or with the ksh93 $'...' quotes (also found in zsh and bash) allowing x escape sequences:
apt-cache search $'desktop(n|$)'
Also note that . does match a newline character. Written in perl, that would be:
print "$name - $summary" if
$name =~ qr$resi ||
$description =~ qr$resi;
(except they are not perl regexps of course)
You might want to explain the$''notation. Most ppl are not familiar with it.
â slmâ¦
Jan 28 '14 at 7:22
Yes, I was about to ask that becauseapt-cache search 'desktop(n|$)'apparently works as well.
â user15760
Jan 28 '14 at 7:24
@vasa1. Hmmm. Weird,'desktop(n|$)'seems to work indeed, but not'desktopn'nor'desktop(n)'. I don't know why.
â Stéphane Chazelas
Jan 28 '14 at 7:27
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with thebapproach.
â slmâ¦
Jan 28 '14 at 7:32
add a comment |Â
up vote
3
down vote
up vote
3
down vote
The description field is a multi-line field but $ in the regexp, means the end of the field, not the end of each line of the field. So, if you want to search for desktop at the end of a line or at the end of the field, you need:
apt-cache search 'desktop(
|$)'
Or with the ksh93 $'...' quotes (also found in zsh and bash) allowing x escape sequences:
apt-cache search $'desktop(n|$)'
Also note that . does match a newline character. Written in perl, that would be:
print "$name - $summary" if
$name =~ qr$resi ||
$description =~ qr$resi;
(except they are not perl regexps of course)
The description field is a multi-line field but $ in the regexp, means the end of the field, not the end of each line of the field. So, if you want to search for desktop at the end of a line or at the end of the field, you need:
apt-cache search 'desktop(
|$)'
Or with the ksh93 $'...' quotes (also found in zsh and bash) allowing x escape sequences:
apt-cache search $'desktop(n|$)'
Also note that . does match a newline character. Written in perl, that would be:
print "$name - $summary" if
$name =~ qr$resi ||
$description =~ qr$resi;
(except they are not perl regexps of course)
edited Jan 28 '14 at 7:38
answered Jan 28 '14 at 7:19
Stéphane Chazelas
289k54535874
289k54535874
You might want to explain the$''notation. Most ppl are not familiar with it.
â slmâ¦
Jan 28 '14 at 7:22
Yes, I was about to ask that becauseapt-cache search 'desktop(n|$)'apparently works as well.
â user15760
Jan 28 '14 at 7:24
@vasa1. Hmmm. Weird,'desktop(n|$)'seems to work indeed, but not'desktopn'nor'desktop(n)'. I don't know why.
â Stéphane Chazelas
Jan 28 '14 at 7:27
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with thebapproach.
â slmâ¦
Jan 28 '14 at 7:32
add a comment |Â
You might want to explain the$''notation. Most ppl are not familiar with it.
â slmâ¦
Jan 28 '14 at 7:22
Yes, I was about to ask that becauseapt-cache search 'desktop(n|$)'apparently works as well.
â user15760
Jan 28 '14 at 7:24
@vasa1. Hmmm. Weird,'desktop(n|$)'seems to work indeed, but not'desktopn'nor'desktop(n)'. I don't know why.
â Stéphane Chazelas
Jan 28 '14 at 7:27
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with thebapproach.
â slmâ¦
Jan 28 '14 at 7:32
You might want to explain the
$'' notation. Most ppl are not familiar with it.â slmâ¦
Jan 28 '14 at 7:22
You might want to explain the
$'' notation. Most ppl are not familiar with it.â slmâ¦
Jan 28 '14 at 7:22
Yes, I was about to ask that because
apt-cache search 'desktop(n|$)' apparently works as well.â user15760
Jan 28 '14 at 7:24
Yes, I was about to ask that because
apt-cache search 'desktop(n|$)' apparently works as well.â user15760
Jan 28 '14 at 7:24
@vasa1. Hmmm. Weird,
'desktop(n|$)' seems to work indeed, but not 'desktopn' nor 'desktop(n)'. I don't know why.â Stéphane Chazelas
Jan 28 '14 at 7:27
@vasa1. Hmmm. Weird,
'desktop(n|$)' seems to work indeed, but not 'desktopn' nor 'desktop(n)'. I don't know why.â Stéphane Chazelas
Jan 28 '14 at 7:27
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with the
b approach.â slmâ¦
Jan 28 '14 at 7:32
@StephaneChazelas - yeah I noticed the 'desktopn' didn't work either. I left it out of my answer as to not confuse the situation further. That's why I went with the
b approach.â slmâ¦
Jan 28 '14 at 7:32
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f111255%2fhow-does-work-in-apt-cache-search-something%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password