sed misbehaving?
I don't know if I'm doing something wrong here, but sed appears to be not working properly on my system. I tried a number of examples from Rute (asper my sig.) and whenever I try a sed command of the the 'sed -e 's/>regexp>/<substitution>/g' type nothing happens.
I tried the following command: Code:
$ ls -l | grep ^-| sed -e 's/^\(<.*> [ ]*\){8}\(.$\)/\2/g' Code:
$ rpm -q sed |
What do you call 'clean' filenames ? The output of this command shows me files as :
-rw-r--r-- 1 keefaz users 60938 2005-11-14 00:06 divx2pass.log (same for each files, no directory in output as the grep ^- explicitly discard them) |
You don't even need the sed because the pattern doesn't match. If you just want the filenames of regular files (assuming no spaces in the filenames)
Code:
ls -l | grep ^-| sed -e 's/.* //g' |
Quote:
But why does it work? Why doesn't it return 'linmix' as well if the ls -l output is '-rwxr-xr-x 1 linmix linmix 232 Dec 2 22:35 test.sh' Also, the book I'm reading (RUTE > see sig.) gives the following example with supposed output: Code:
$ sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' |
That should be :
Code:
sed -e 's/\([^ ]\+\)\( \+\)\([^ ]\+\)/\3\2\1/g' \( \+\) : match one or more space |
Brilliant!
Quote:
|
1. no idea, anybody can make mistake, it is a human feature :p
2. Open a terminal and type : info sed |
1. Well, the books ben around for +10 years and has been updated, plus it's used by quite some institutions to teach linux courses, so somebody might have noticed before now...
2. info sed has a lot of info, but i'm looking for a tutorial, something with practical examples to see what happens (or should happen). It's just the way I learn best :) |
Quote:
|
So imagine I want sed to return 'linmix' .. how would I go about it?
|
All times are GMT -5. The time now is 06:37 AM. |