hi experts,
anyone knows how can i find a string in a multiple binary files in a multiple directories and display the file name containing the string?
i mean i have lots of folders with binary files and i am looking for specific string within one of these files i would like to know the right syntax to use for this kind of search, i know i should run strings or something similar.
i used the first code and got
i am trying to find a string SRV6000 and another string srv6000, i would like to know which file contain this string most probably will be a binary file in the machine.
hi experts,
anyone knows how can i find a string in a multiple binary files in a multiple directories and display the file name containing the string?
i mean i have lots of folders with binary files and i am looking for specific string within one of these files i would like to know the right syntax to use for this kind of search, i know i should run strings or something similar.
OS Solaris 10 sparc
You are correct in noting that you need to use strings when looking for a string in a binary file. The grep utility is only defined to work on text files. This may not be highly efficient, but it should do what you want. First create the following shell script as a file named $HOME/bin/st_gr_pr:
and make it executable using the command:
Note that the -i option to the grep command in this script makes searches for alphabetic characters case insensitive. I use ksh, but bash should also work if you want to use it in this script.
Then run the command:
to get a list of all regular files rooted in the current directory that contain srv6000, SRV6000, or any of the other six strings with combinations of uppercase and lowercase s, r, and v in that order. Obviously, replace srv6000 if you want to find files containing a different pattern.
Last edited by Don Cragun; 01-29-2013 at 12:29 PM..
This User Gave Thanks to Don Cragun For This Post:
Solaris 10 may also have ggrep (i.e. GNU grep - depending on the actual Update of Solaris 10) under /usr/sfw/bin.
As you can see, you can use the -a option to treat all files as ascii text, and -l to just list the filename that matches. Leave off the -l to print the actual line that matches.
You are correct in noting that you need to use strings when looking for a string in a binary file. The grep utility is only defined to work on text files. This may not be highly efficient, but it should do what you want. First create the following shell script as a file named $HOME/bin/st_gr_pr:
and make it executable using the command:
Note that the -i option to the grep command in this script makes searches for alphabetic characters case insensitive. I use ksh, but bash should also work if you want to use it in this script.
Then run the command:
to get a list of all regular files rooted in the current directory that contain srv6000, SRV6000, or any of the other six strings with combinations of uppercase and lowercase s, r, and v in that order. Obviously, replace srv6000 if you want to find files containing a different pattern.
Hi,
I am not a C programmer. The only C exposure I have is reading and completing the exercises from the C (ANSI C ) Programming Language book:o
At the moment, I am using the UNIX strings command to extract information for a binary file and grepping for a particular string and the value... (3 Replies)
Hello *nix specialists,
Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
I am struck up with a problem and that is with output redirection.
I used all the ways for the redirection of the output of c binary to a file, still it is failing.
Here are the different ways which I have used:
./a.out | tee -a /root/tmp.txt 2>&1
./a.out | tee -a /root/tmp.txt 1>&1
./a.out |... (2 Replies)
Hi All,
Iam new to unix scripting and I want a split a string into 4 characters each, leaving the last two characters and convert the splitted values into binary.
For example:
string='ffd80012ffe20000ffebfffeffea0007fff0ffd70014fff1fff0fff0fff201'
this should split as
ffd8
0012
ffe2
.
.... (5 Replies)
Hi,
I have a problem that I am sure someone will know the answer to. Currently I have a script which returns a binary output if it finds a certain search string (in this case relating to a DRBD cluster) as follows:
searchstring="cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate"
&& echo... (3 Replies)
Hi all,
I have a binary file (orig.dat) and two special delimiter strings 'AAA' and 'BBB'. My binary file's content is as follow:
<Data1.1>AAA<Data1.2>BBB
<Data2.1>AAA<Data2.2>BBB
...
<DataN.1>AAA<DataN.2>BBB
DataX.Y might have any length, and contains any kind of special/printable... (1 Reply)
Hi,
I have two Solaris machines.
1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500
2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60
I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
please let me know that in unix using c programming language we can do binary to string conversion and vice versa using ltoa and atol but how can we do it in c++ programming language.
thank you in advance. (3 Replies)