1 |
On Tuesday 07 November 2006 20:32, Drake Wyrm wrote: |
2 |
> I could be missing something, but: |
3 |
> |
4 |
> [[ $'\nwombat' =~ $'wombat' ]] && \ |
5 |
> echo "These compare as equal, with or without the leading \n" |
6 |
|
7 |
A working example in bash-3.2 :) |
8 |
|
9 |
[[ $(</proc/mounts) =~ $'\n'/dev/root\ ]] \ |
10 |
&& echo "Yay, I matched ^/dev/root " |
11 |
|
12 |
I challenge you to get an exact match of /dev/root being on the first line |
13 |
using the == operator and/or quoting. |
14 |
Remember, /dev/root/foo and /dev/foo /dev/root must not match either. |
15 |
|
16 |
If you can you get credit in the ChangeLog :) |
17 |
|
18 |
Yes, you could also write |
19 |
grep -E "^/dev/root " /proc/mounts, but using bash like this is faster [1] |
20 |
|
21 |
[1] http://roy.marples.name/node/267 |
22 |
|
23 |
Thanks |
24 |
|
25 |
-- |
26 |
Roy Marples <uberlord@g.o> |
27 |
Gentoo/Linux Developer (baselayout, networking) |
28 |
-- |
29 |
gentoo-dev@g.o mailing list |