I copied the following from my linux console.
grep -lr "SMTP" *.ini
grep: *.ini: No such file or directory
I wanted to search recursively under current location in files with extenstion .ini
Actually there are files that contain "SMTP" under this directory. But I got the above error message.
What is wrong? I am using centos 6.
Thanks,
3rock
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?
Hello, I have an embedded linux device. I can connect to the device and I can upload or download files. No problem with this. But, at first connection, I want to connect to "/" directory instead of "/root". In the device file system, there are files ssh_config and sshd_config under /etc/ssh directory. I think I have to do something with these files but I don't know what.
I don't exactly know what mean "/root" and "/" directories. I think that the real root directory is "/" directory which is empty but when I connect with filezilla, the "/root" directory is the default so I had to go back to / directory everytime.
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
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?
hello all,
please help me with python ftplib. i was trying to copy files from my linux machine to a windows server using ftplib. everything was working good. but i'm only able to copy files from the same directory the script is. how do i copy files from a different directory? i always get "file not found error message". here's my code :
Code:
tester_name = str (socket.gethostname())
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
else:
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
parse_source_path = ('/path/to/where/i/go/')
parse_source_file_list = os.listdir(parse_source_path)
ftp = ftplib.FTP("server_IP")
ftp.login("username", "pass")
folder_list = []
ftp.dir(folder_list.append)
if str(tester_name) not in str(folder_list) :
ftp.mkd("%s"%tester_name)
ftp.cwd("%s"%tester_name)
for files in parse_source_file_list :
print files
upload(ftp, files)
else :
print "later"
If there is one Windows XP feature that I greatly miss in Mint, it is the Search Companion.
I have been struggling with 'grep' in order to create something suitable but with limited success. Take the following problem:-
I wish to interrogate the folder home/dell/Documents/Domestic/Recipes, searching for all files containing the word "mushroom" or "mushrooms", ignoring case. (I can manage the latter. )
Each individual file search should terminate at the first instance of a match and move to the next file. (Recursive, yeh?) Only the file names need to be listed and the output should be paged to allow for easier reading of long lists.
Several different types of file may be involved, including .doc, .odt, .txt .pdf, .htm and .rtf. It would be nice to include all of them in one command. (Wild card behaviour in grep is not entirely predictable - at least not for me.) Running a separate grep command for each different file type would be tedious.
A significant difficulty is that, if grep fails with a syntax, or run-time error, it generally reports the fact but it also has a habit of producing no output, perhaps not returning to the command prompt, whilst sitting inviting the user to decide what to do next. What makes this particularly frustrating is that some file types might not be amenable to a grep search. Text in .txt files and, it would appear, .doc files appears to be searchable but I suspect that .odt files might be more problematic. The snag in such circumstances is trying to interpret grep's response. Does a null return mean that no match was found or that the file format cannot be successfully interrogated? Such failure might not be apparent if the associated file names are simply excluded from the output list.
Apart from grep, is there any other software that would do the job? Sadly LibreOffice Writer seems to be lacking in this area.
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
Hello there. Im stuck on a task.
it`s the task:
Search the file 'data' for all of the lines that contain the pattern 'linux'
and put those lines in the file 'matches'.
You entered: grep "linux" date > matches
Please try again.
I tried lots of variants
1) grep linux date > matches
2) grep 'linux' date > matches
3) grep linux date >> matches
May be something`s wrong with grep command?
I just dont get it >.>; it should work fine. Where is my mistake folks?
Hello all,
I am trying to figure out how to get bash to view for any contents in the "the_difference_between_today_and_yesterday.txt" file and then act if there is anything in the file. I thought i had it, but it is not working like I thought. Any ideas?
Code:
if [ -f final_version_$dater.txt ];
then
if [ -f final_version_$yester_dater.txt ];
then
diff final_version_$dater.txt final_version_$yester_dater.txt | grep "^>" | sed 's/>\ //g' > the_difference_between_today_and_yesterday.txt
if grep ^[a-z]* "the_difference_between_today_and_yesterday.txt";
then
cp the_difference_between_today_and_yesterday.txt /tmp/24hourlemons_table; mysqlimport --user=USERNAME --password=PASSWORD --columns=name,start_date,end_date,link_url,location \
--fields-terminated-by=':' --lines-terminated-by='\n' carshows /tmp/24hourlemons_table; rm final_version_$three_days_later.txt
else
echo "There were no differences between the two files"; rm final_version_$three_days_later.txt
fi
else
echo "ERROR! The file of: final_version_$yester_dater.txt does not exist" >> error.log
fi
fi
hello everyone,
I created a script file (info.sh) in linux centos 6.
location of file is '/etc/init.d/info.sh'
content of file is:
#!/bin/sh
#To get the MAC address
ifconfig | grep HWaddr
#To get the HDD serial no.
hdparm -I /dev/sd? | grep 'Serial\ Number'
#To get the HDD size
hdparm -I /dev/sda |grep "device size"
gave the permission by: chmod 777 /etc/init.d/info.sh
but when i run this file by: /etc/init.d/info.sh
it gives an error like...
-bash: /etc/init.d/info: cannot execute binary file
what should i do?? Actually i have to run this file during boot up..
thanks in advance..