1843857 Members
2351 Online
110225 Solutions
New Discussion

sed script

 
SOLVED
Go to solution
Catherine_3
Occasional Advisor

sed script

I found a shell script about sed,
but I don't understand one of the sentences,
pls help me explain it, thanks in advance.

LOGFILE="$(sed -n -e"s#.8[ ]/#/#p" /f1)"

note f1:
#$Revision:
#configuration file
mail.debug /var/syslog/mail.log
*.info;mail.none /var/syslog/syslog.log
4 REPLIES 4
Catherine_3
Occasional Advisor

Re: sed script

sorry
the sentence is
LOGFILE="$(sed -n -e"s#.*[ ]/#/#p" /f1)"
H.Merijn Brand (procura
Honored Contributor
Solution

Re: sed script

--8<--- f1
#$Revision:
#configuration file
mail.debug /var/syslog/mail.log
*.info;mail.none /var/syslog/syslog.log
-->8---


LOGFILE="$(sed -n -e"s#.*[ ]/#/#p" /f1)"

read every line in file "/f1", but don't print. If and only if a substitution passes that can change all characters leading to a space followed by a slash, changed to a slash:

mail.debug /var/syslog/mail.log
will become
/var/syslog/mail.log

and

*.info;mail.none /var/syslog/syslog.log
will become
/var/syslog/syslog.log


# sed -n -e"s#.*[ ]/#/#p" /f1
/var/syslog/mail.log
/var/syslog/syslog.log
#

The output of the sed command will then be stored in the variable LOGFILE (this is POSIX shell syntax)

man sed would have helped I guess
Enjoy, Have FUN! H.Merijn
Victor_5
Trusted Contributor

Re: sed script

Hi Catherine:

I think Procura's explanation is clear enough. Yes, the man page also is very helpful.

Don't forget assign points to Procura.

3L
Catherine_3
Occasional Advisor

Re: sed script

Hi Procura,

Thanks a lot