LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2015, 09:14 AM   #1
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Rep: Reputation: 5
Problem with .bashrc entry


I need to execute this .bashrc string:

alias lml='grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' mail.log | grep "relay=" | awk '{print $8}'' #list mail log

I have tried enclosing the string in alias as lml="..." and alias lml=`...` to no avail. The problem is apparently with the grep "relay=" in that it has to be enclosed in "", as well as the awk that has to be enclosed in ''.

Any ideas on how to get this setup? Thanks.
 
Old 02-14-2015, 09:43 AM   #2
yooy
Senior Member
 
Registered: Dec 2009
Posts: 1,387

Rep: Reputation: 173Reputation: 173
small script maybe?
 
Old 02-14-2015, 11:13 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Try this:

alias lml="grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' mail.log | grep 'relay=' | awk '{print $8}'"

It was actually a shell quoting problem.
 
Old 02-14-2015, 06:40 PM   #4
battles
Member
 
Registered: Apr 2014
Distribution: Debian GNU/Linux 7.5 (wheezy)
Posts: 231

Original Poster
Rep: Reputation: 5
No, that doesn't work. It gives me this:

Feb 14 17:34:52 me postfix/smtp[31127]: 7B95481E68: to=<him@his.net>, relay=mail.his.net[123.456.78.90]:25, delay=1.7, delays=0.02/0.02/0.86/0.83, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as A2F12380413)

where I am looking for this (which is what the string gives when executed at prompt):

relay=mail.him.net[123.456.78.90]:25,

The script idea is probably the best.

Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /etc/bashrc ,dircolors and /root/.bash_profile ,/.bashrc not exist in LFS-7.5(sec9.3) jaassi Linux From Scratch 2 09-20-2014 06:04 PM
~/.bashrc, /etc/bash.bashrc files not read? Tachtory Slackware 3 01-04-2014 01:25 AM
[SOLVED] How to use my /home/kangjoo/.bashrc rather than root/.bashrc kangjoo.lee Linux - Newbie 2 11-05-2012 04:38 PM
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 11:59 PM
.bashrc problem davis2199 Linux - Software 1 09-02-2003 04:45 PM


All times are GMT -5. The time now is 09:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration