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.


Similar Content



Print Column With A String Using Awk Or Grep

Hi All,

Using grep command with a defined string, you will get the row. Can I get the column instead of row? For example,

the file content is as below:

AA BB
123 456
789 ABE

execute 'grep ABE file' will give you "789 ABE". Is there any way to get the column:
BB
456
ABE
?

Thank you very much.

Sendmail Is Not Working

Hi all,

I am trying to configure sendmail on my OEL 6.5 running on VM.

I did below to set it :

1. # yum install m4 telnet mailx
2. # yum install sendmail sendmail-cf
3. # ps -ef | grep -v grep | grep -i sendmail
root 3805 1 0 05:58 ? 00:00:00 sendmail: accepting connections
smmsp 3815 1 0 05:58 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue

4. # netstat -an | grep :25 | grep tcp
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

5. vi /etc/mail/sendmail.mc

From:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

To
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

6. # m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

7. # service sendmail restart

8. # vi /etc/mail/local-host-names
oracle.com

Now if I am sending mail from 1 user (root) to other user (oracle)

$ mail -s "Test mail from root" oracle
Hello this is the test mail
.
EOT

and checking mail log under /var/mail/oracle, its passing successfully.

But when trying to send the same from root user to my company outlook account not gtting any mail.

mail -s "Test mail from root" abc.xyz@aaaa.com (trying to send to my outlook account)

Getting below error on /var/log/maillog :

May 13 10:47:47 mydb sendmail[6306]: t4DEllUD006306: from=oracle, size=244, class=0, nrcpts=1, msgid=<201505131447.t4DEllUD006306@mydb.oracle.com>, relay=root@localhost
May 13 10:47:47 mydb sendmail[6307]: t4DEllxo006307: from=<oracle@mydb.oracle.com>, size=506, class=0, nrcpts=1, msgid=<201505131447.t4DEllUD006306@mydb.oracle.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
May 13 10:47:47 mydb sendmail[6306]: t4DEllUD006306: to=abc.xyz@aaaa.com, ctladdr=oracle (600/601), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30244, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t4DEllxo006307 Message accepted for delivery)
May 13 10:47:49 mydb sendmail[6309]: STARTTLS=client, relay=mail1.nic.aaaa.com., version=TLSv1/SSLv3, verify=FAIL, cipher=AES256-SHA, bits=256/256
May 13 10:47:50 mydb sendmail[6309]: t4DEllxo006307: to=<abc.xyz@aaaa.com>, ctladdr=<oracle@mydb.oracle.com> (600/601), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120506, relay=mail1.nic.aaaa.com. [192.240.6.6], dsn=2.0.0, stat=Sent (1uc8dar1s7-1 Message accepted for delivery)

Please suggest if something I missed out or any other problem

Thanks,

New Problem With Aliases

I have many .bashrc aliases. When I used to type in an alias, it just executed the alias. Now something has changed. When I type in the alias, it prints the alias lines and then executes the commands:

alias cde='cd /etc/ && ls --color -a' #get to /etc

root@me~# cde
cd /etc/
ls --color -a
...into /etc and list of folders/files follows...

How can I stop the

cd /etc/
ls --color -a

from being displayed?

Thanks.

Using Xargs And Grep In Find Command

I've been using this a lot:

find <directory to start search at> -name "<files to search in>" -type f | xargs grep "<string to search for>"

e.g.

find /usr/include -name "*.h" -type f | xargs grep "#define UINT"

now what if I wanted to output the results to a file?

How Can I Grep Variable?

I want to And search grep shell

but It's hard to grep variable


---------------------------------------------------------------
#!/bin/bash


if [ $# -eq 0 ]
then
echo "Ussage: phone searchfor [...searchfor]"
echo "(You didn't tell me what you want to search for )"

else

pass=0
find=""

for idx in $*
do
if [ -n "$idx" ]
then
if [ $pass -eq 0 ]
then
find=$(egrep "$idx" mydata)
pass=1

else

find=$("$find" | grep "$idx")

echo $find
fi
fi

done

if [ -z "$find" ]
then
echo "There is no such thing"
else

echo $find | awk -f display.awk

fi

fi

-----------------------------------------------------

there is one error : command not found

in find=$("$find" | grep "$idx")

how can I grep variable and store it into variable?

Sendmail Alias Not Working

I'm trying to send all root's mails to an external e-mailaddress, but for some reason I can't get it to work.

I've edited /etc/aliases with the following rule:

root: <myexternal@email.address>

and run newaliasses after, which would run without any errors.

I can run: echo "Testing" | mail -s "Server Testing" <myexternal@email.address>
just fine without any issue and it's being delivered correctly to my external address.

But when I run: echo "Testing" | mail -s "Server Testing" root

I (first) get a "Deferred: 451 Temporary local problem - please try again later" error and when I then run: "Sendmail -OTimeout.hoststatus=0m -q -v" to flush the mailqueue it says everything is ok, but I then get a message saying I have new mail in /var/spool/mail/root and I don't get the mail on my external e-mailaddress.

I have no clue where to look next, hopefully you guys can point me in the right direction.

Just for completeness: I use mageia release 4 (x86_x64).

How I Can Print A Specific Range Of Nubers Form A File.

hello,

i am trying to make a table from some files. i used this to record how much "RD_" field i have in my file. Quote:
grep -o 'RD_' $f|grep -c 'RD_'
forexample i got 5 "RD_" fields now i want to print 5 number of fields from another file starting from 2nd field. i did it mannully like Quote:
awk 'NR==1{print"{"$2","$3","$4","$5","$6","0.0000",""0.0000""}"","}' $file
i want to make it work together and a bit auto matic like PHP Code:
awk 'NR==1{print"{"$2"to "$5"," apend zeros to make it total 7 fields"}"","}' $file 


your coments would be apreciated
thanks alot

Recursive Xterms Via .bashrc

I made the mistake of adding an xterm invocation to my ".bashrc" file. My intent was to simply execute an xterm upon initial login to the KDE environment on Debian Wheezy (though the distro probably would have made no difference). What happened is that with each invocation of "xterm", the new xterm would again invoke an "xterm" via the ".bashrc" file. Duh, infinite recursion of xterms upon login. Is there a simple way to invoke an xterm at login that doesn't itself lookup the ".bashrc" file? By the time someone answers this, I will probably find and answer somewhere in the bash/xterm man pages, but thought I'd throw it out there. Really felt stupid after having realized my mistake. Had to login to recovery command line mode and replace the ".bashrc" file with "/etc/skel/.bashrc". Cheerio

Grep: Find Files That Do Not Have Multiple Different Strings

Hi all,

I'm trying to identify files that do not have matches for certain strings. FYI, these are files of DNA sequences and I'm trying to find those that are NOT sampled for any species by my group of interest (e.g., genes that are specific to that group of organisms).

I tried this code but it's actually yielding a list of files that DO match for my regexp.
Code:
for FILENAME in *.fas
do
grep -q -L ">PBAH" $FILENAME && grep -q -L ">SKOW" $FILENAME && grep -q -L ">CGRA" $FILENAME && echo $FILENAME
done

Basically I want to somehow go through and file files that do not contain ">PBAH" ">SKOW" or ">CGRA". Any assistance would be greatly appreciated!

Best,
Kevin

Awk On Remote Server

Hi,

I am running awk command on remote server it is not giving desired results but if i run the same command on local server. it works as expected. Can anybody help me to resolve this and let me know the logic behind this?

Remote server

# ssh test 'free -g | grep Mem | awk -F " " '{ print $2 }''
awk: cmd. line:1: {
awk: cmd. line:1: ^ unexpected newline or end of string

local server
# free -g | grep Mem | awk -F " " '{ print $2 }'
31


Thanks in advance.