this post has been archived.
this post has been archived.
Ok, I have a line that looks like this:
29760 pts/1 S+ 0:00 sh -c madplay -b 16 -R 44100 -S -o raw:- "/home/ices/music/Modest Mouse - Ocean Breathes Salty.mp3" | lame --preset cbr 96 -r -x -s 44.1 --bitwidth 16 - -
and I want to remove everything before /music/ and everything after .mp3"
I've been hacking away with sed and haven't gotten it to work yet. Maybe someone wants to take a crack at it?
damn it, I figured it out
sed -e 's/[: -+0-9a-zA-Z\"]*music\///g' -e 's/.mp3[: -+0-9a-zA-Z\"\|\-]*//'
asemisldkfj
the law is no protection
I probably hate regular expressions more than any other computer-related thing. I have NEVER been able to wrap my head around them and it frustrates me to no end when I try.
I need someone to sit me down and give me an hour-long crash course in them or something.
ya when you do, try recoding the damn url regexp for ttf
ok, now that shit is starting to work and I *think* I understand it, I think its pretty cool.
oh man, regex is where i thrive. probably my fav. thing in programming.
it's a sick addiction to line noise i guess
what happened to db-is-on-ttf-regexp?
i started teaching a class...
ttf url regexp assignment for students?
:D
dooo eeeet!
how come the first one doesn't work but the second one does? i shouldn't be escaping a metacharacter. does the shell need it escaped, which then passes it to grep unescaped?
$ df | grep '^.* +/usr/home$'
$ df | grep '^.* \+/usr/home$'
/dev/concat/gc9a 1210925126 1031973254 82077862 93% /usr/home
$
is there a way to use awk instead of both grep and awk for the following?
$ df | grep '^.* \+/usr/home$' | awk '{ sub(/%/,"",$5); print $5}'
93
$
this is probably the best one to avoid false positives:
$ df | grep '^.*% \+/usr/home$' | awk '{ sub(/%/,"",$5); print $5}'
93
$
for example:
$ df
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/mirror/gm9s1a 507630 339824 127196 73% /
devfs 1 1 0 100% /dev
/dev/mirror/gm9s1d 507630 22 466998 0% /tmp
/dev/mirror/gm9s1e 2026030 379118 1484830 20% /var
/dev/mirror/gm9s1f 231437172 2351436 210570764 1% /usr
/dev/concat/gc9a 1210925126 1031973170 82077946 93% /usr/home
//LUCAS@PENELOPIA/ATLAS 312560608 19527916 293032692 6% /joke/ha ha ha /usr/home
$ df | grep '^.* \+/usr/home$' | awk '{ sub(/%/,"",$5); print $5}'
93
6
$ df | grep '^.*% \+/usr/home$' | awk '{ sub(/%/,"",$5); print $5}'
93
$
ugh, even percent signs can be part of a directory name. :[
i'm following along on atlas, trying some stuff out.
$ df | awk '/home/ {sub(/%/,"",$5); print $5}'
$ df | awk '/\/usr\/home/ {sub(/%/,"",$5); print $5}'
For the record, this works:
$ df | grep -E '^.* +/usr/home$'
From the grep manual: "In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, \+, \{, \|, \(, and \)."
"Basic regular expressions" here means what simply running "grep" uses. With -E it uses the "extended regular expressions". If you're lucky your grep supports -P and then you can use all the Perl stuff in the regexes.
oh. thanks!