General :: Fastest Way To Search For Strings?
Jan 29, 2010
Is there a faster way to search for a file containing a given string than using grep -re "string" /
This takes a long time to search through the entire system, so I was wondering if there is a faster way. I don't know the name of the file, just that it will contain a given string.
View 4 Replies
ADVERTISEMENT
Nov 15, 2010
I am using sed to process an ascii tcpdump file whereby each packet is processed into a line with the same number of columns and useful information is pulled out like the time, packet type, length, and also IP addresses, payload type and port numbers where appropriate. The time is already changed to seconds, followed by the protocol over ethernet, such as IP, IP6, ARP etc. and I can change anything it detects as IP, IP6 and ARP into some other string, pulling out necessary information depending on the protocol and payload.The beginning part of the search for IP starts with the sed search /([0-9][0-9]*.[0-9][0-9]*)[ ]IP[ ,] ... /, where time is in seconds and ellipses means more stuff, and likewise for IP6 and ARP.But how do I process the lines that are NOT IP, IP6 or ARP? (Specifically NOT /IP[ ,]/, /IP6[ ,]/ or /ARP[ ,]/.) So that I can format them into a string with the same number of columns.
View 2 Replies
View Related
May 19, 2011
What would be the best way to search for a file that contains a string similar to this:
View 1 Replies
View Related
Feb 3, 2011
Long story short, I got a folder with nearly 800,000 php files. I would like to search each file for a string and if it exists in that file, the file gets copied to another directory. Is this possible from the terminal? So far I got: grep -i -n -r 'ppr-1792' * | cp $1 move_to_here
But this obviously doesn't work. $1 needs to be the file name that contains matching text.
View 2 Replies
View Related
Jun 8, 2011
How can i use different starting and ending delimiters in awk to search for strings or numbers like:
:string"another_string
'number+another_number
now i want string and number as output from above lines. But if i use delimiter as : or ' it will print the entire line coz second delimiter is not same as first one.
View 4 Replies
View Related
Jul 29, 2010
I want to search and replace strings in a file with strings in other files/i need to do it with big strings(string1 is big) and i want to use a txt file for this.But this code not working :
View 14 Replies
View Related
Jul 16, 2010
Something very handy to do in a Linux shell, is manipulating files and strings - essentially parsing data. Write a utility which will scan in a text file and search and replace strings. We also want to keep track of how many strings we've replaced.
I know that my command would look like this: <utility name> <filename> <stringToSearchFor> <stringToReplaceWith>
Code: #!/bin/bash
[code]....
View 2 Replies
View Related
Feb 23, 2010
This should be simple but I can't seem to find what I am looking for.I want to search a text file for the existence of certain strings and execute a command if they exist, something along the lines of:
if <string> exists
command
or
if <any member of this list exists>
command
I know how to manually search a file with grep, cat, etc., but the "if this exists" part eludes me.
View 7 Replies
View Related
Feb 19, 2011
I have an ext2 formatted disk (linux) and I need to reformat it to NTFS (windows). Problem is, I have to retain the 750 GB of data that's on the disk. What's the quickest (least number of steps) way to accomplish this? I do have a spare 1TB disk now to help with the transfer.
Background.I've been using XBMC Live for a couple of years, but with all the problems I've been having lately, I'm moving over to the Windows version. Unfortunately all of my media is stored on an ext2 formatted disk (not the same disk as the OS disk).I was thinking of loading up an Ubuntu live disk, and installing ntfs-config. Mount my secondary disk (already formatted NTFS), transfer the files, reformat the original drive, load windows and transfer the files back.
View 3 Replies
View Related
Jul 20, 2011
I'm on Ubuntu 11.04. I get the above error when running a utility to get code from a version control system (StarTeam). The error looks generic enough that I'm hoping its an easily resolvable system problem. Below is how I get it ...
Code:
$ /bin/sh -c stcmd label -x -nologo -stop -p username:password@mydomain.com:9999/NNA/NNA/Technology/nna/tools/selenium -nl selenium-utils-1.0 -b
strings: '/lib/libc.so.6': No such file
[code].....
View 1 Replies
View Related
May 11, 2011
Let me know unix commands to implement set operations on strings.
View 9 Replies
View Related
Jun 30, 2010
i have an old laptop (compaq armada m700... a piii with 576mb ram!!!) which i seldomly use. i have always "wished" i could use this old (and slow and crippled) laptop to do something basic, very basic: to connect to the internet, browse my email, maybe download and read a pdf, watch some stupid videos videos (-not in hd, of course i know!)... and that's about it (no gaming, no office, no photoshoping, no anything else!). but i wanted to do that in style: fast and without hazzle -as 'in having to navigate thru somehow obscure prompt commands or similar!'.
i've tried installing a bare tinyxp... but yet it takes forever to start up, load... and be ready to navigate. i've also looked at the linux world -albeit i am clueless on this os- and i tried installing different flavours of ubuntu and others. unfortunately results weren't much better than with tinyxp -in regards of starting up and responding to user interaction in a reasonably and timely manner. lately i've hear about the (in)famous chrome or chromium or whatever... but it seems it's not going to be ready for a while just yet and it won't necessarely work on such old laptops like mine
View 2 Replies
View Related
Jan 15, 2010
fakeFile's contents :
Code:
blah $(date +%F) blah
fakeScript's contents :
Code:
while read line; do
echo $line
done < "fakeFile"
so here's the problem : is there any way to evaluate the fakeFile's contents (in the fakeScript), so that the term "$(date +%F)" (or any other bash script) in a string , translates to it's corresponding value ? (in this example , we want to have "blah current date" instead of " blah $(bash script) blah " )
View 9 Replies
View Related
Mar 22, 2010
I would like to find all the files that contains the strings I'm searching.
For example (it's just an example), I would like to search all the files in "/etc" that contains "eth0" and "us", whatever where are located those 2 strings, the important is that the 2 strings are in the files listed.
It would be something like a "grep -lr 'eth0' *" and "grep -lr 'us' *" but in one time/command, so that I don't have to make a comparison of the 2 list of files resulting from the 2 "grep" commands given higher.
View 10 Replies
View Related
Jun 24, 2011
I have this piece of code with some template strings.
Code:
Big_L: $Big_L
$Big_R
$Lambda_tf
$Epsilon_1
$mu
$n_0
$ms
$Delta_R
$Epsilon_2
$Lambda_d
$Epsilon_3
$Small_N
$Small_Q
How can I insert exactly the same template strings in front of each string, but just without the '$' sign (see the first line for an example)?
View 7 Replies
View Related
Oct 5, 2010
I've been surfing and searching the net quit a while now to make my own script, but I haven't been really successful ever since I want to make a script which can remove strings from my mp3 collection (file names).
For example:
Code:
101-bob_sinclar_feat_sean_paul-tik_tok_(radio_edit).mp3 --> bob_sinclar_feat_sean_paul-tik_tok_(radio_edit).mp3
10-Young Jeezy-Lose My Mind (78 Bpm) (Repack).mp3 --> young_jeezy-lose_my_mind.mp3
Now the problem is how can I remove the strings like:
101 & 10 (dynamic)
(%%% Bpm) (dynamic)
(Repack) (static)
View 11 Replies
View Related
Jan 31, 2010
In bash, I would like to remove all zeros (if exist) from the beginning of a strings:
000001234
00123
0000568
View 9 Replies
View Related
Nov 16, 2010
I have multiple strings (eg. say two, firstLIST=(0 1 2) and secondLIST=(2 3)) and want to create a single string composed of their unique sorted elements. For the sample strings above, I'd like to build masterLIST=(0 1 2 3).I suppose I could write the elements of firstLIST and secondLIST to files
Code:
echo ${firstLIST[@]} > firstFILE
echo ${secondLIST[@]} > secondFILE
then use
Code:
sort firstFILE secondFILE | uniq > masterFILE
as this gives me a file populated with the elements I'm after, but I'm not sure how to read the elements back into masterLIST... and it doesn't seem "right" to create files to accomplish this. Is there a way to do this by manipulating the strings ${firstLIST[@]} and ${secondLIST[@]} directly? The closest I've come (not close at all) is
Code:
masterLIST=${firstLIST[@]}" "${secondLIST[@]}
but masterLIST built this way has only one element
Code:
$echo ${masterLIST[@]}
0 1 2 2 3
$echo ${#masterLIST[@]}
1
and I don't have access to the individual digits to then try to figure out how to remove duplicates.
View 4 Replies
View Related
Mar 13, 2011
I'm trying to write a bash script to find all lines containing two different strings in many files. I don't have access to egrep so I want to use sed for this purpose.
The files will look like this:
FileX
------
Info:18
Data:76
Contact:me@home.com
Start:1500
I want to generate a new file from these files with only the rows containing Data and Start. Something like this:
for y in `ls /file*.db`;
do sed '/Data|Start/p' $y > newfile
done
View 7 Replies
View Related
May 16, 2011
i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:
Code:
#!/usr/bin/awk -f
BEGIN{
RS="[[:space:]]+";
ORS=""
[Code].....
View 2 Replies
View Related
Dec 9, 2010
I've got a quick grep question. I'm trying to work out a command I can use to locate all of the files in a directory that have sql database connection details. I want to do it by looking for the strings "localhost" and the name of the database.find . -type f -exec grep -l -E '^(localhost|DATABASE_NAME)' {} ;
View 4 Replies
View Related
Mar 21, 2010
I have a file with no regular way to grep or sed for any regular expression. The wordings, fields, spacings are random. code...
I want to extract character positions 3 to 10 including spaces. code...
View 8 Replies
View Related
May 10, 2011
I got requirement to find the difference between two strings and write the difference to new file by comparing the substrings separted by commas
Below mentioned is an example of requirement
String1 --> ABC,DEF,GHI,JKL
String2 --> MNO,ABC,XYZ,DEF
In String1 and String2 the substrings are separted by commas. The substrings which are common between String1 and String2 are ABC,DEF this common substrings has to be written to a file say common.txt ( having the text ABC,DEF). And the substrings GHI,JKL in String1 which are not present in String2 has to be written to another file say String1Extra.txt (having the text GHI,JKL). In the same way the substrings MNO,XYZ from String2 which are not present in String1 has to be written to another file say String2Extras.txt(having the text MNO,XYZ) .
View 1 Replies
View Related
Jul 29, 2010
what command is to be used to call strings from other files to the script and then comparing strings from two different files in the script to check if strings are matched then return the result to another script.
View 1 Replies
View Related
Nov 2, 2010
I'm studying about signal in Linux Kernel and I got a problem about signal handler and output buffer.
I just want to know about stdout buffer related parent process and child process.
The problem is - parent process received SIGINT signal_handler that I implement is called. And after signal_handler is called, it print string "pid : xxx state : RUNNING" ... but after end of signal_handler function, child process might be print string but it isn't print at all.
I'm not asking right code, but I want to know why is this happened and concepts about signal handler, buffer - between parent process and child process.
here is a code signal_handler:
Quote:
void TC3_handler()
{
pid_t pid;
ProcState ps;
pid = GetProcessId();
[Code]....
chlid process counts number in infinite loop, but after call signal_handler, it can't print at all.. just waiting for SIGINT..
View 2 Replies
View Related
Jan 7, 2010
Here as I sit, happily with my Ubuntu and GNOME. I really like the GNOME in many ways. Alas, I admit that the desktop UI initializes in a meager .5 second really gets me. So why am I looking at KDE if I'm happy with this GNOME? Read on...Cause I'm not. I confess the GNOME isn't as pretty as KDE. Then I read a Slackware users' love of KDE (looking at you, ~sHyLoCk~), then I go on and read Linuz Torvalds criticism of GNOME. I see KDEs apps constantly being referred to as elite. And eyecandy? Well, GNOME has zip (not .zip ).Then I want to change something somewhere in the UI in gnome and I have to open a dreaded Registry Editor. I have had enough torture with that, with you-know-who, Mr. Gates! (Ok, ok, its Gconf. Whatever. Still has hives and strange string data, hiding away things...making things harder and more complicated).
So now I'm all for KDE right? Maybe. Every distro I have tried with KDE, Slackware (God of the Linux), Gentoo (Sabayon) [supposedly optimized for hardware for speed....hrmph...), Kubuntu (1:27 sec boot time), Fedora with KDE (Pathetic), BackTrack 4 (System_not_responsive) and a few others I probably have forgotten. Guess what?ower than molasses in January. Boot times 1 minute +... 10 seconds plus for an app to load up...Even the mouse gets choppy. GNOME distros? Fast. (well, a few of them are, anyway...)I've read distrowatch like an Almanac, scoured polishlinux.org...Haven't seen nothing.So I guess I'm going to ask you KDE fans, is there some obscure optimization thats needed?
View 12 Replies
View Related
Mar 17, 2011
Trying to remove lines from a syslog text file that have duplicate strings
Mar 10 06:51:11[http-8080-1] INFO com.MYCOMPANY.webservices.userservice.web.UserServiceController [u:2533274802474744|360] Authorize [platformI$tformIdAndOs=2533274802474744|360, userRegion=America|360]
then a few lines down
Mar 10 06:52:03 [http-8080-1] INFO com.MYCOMPANY.webservices.userservice.web.UserServiceController [u:2533274802474744|360] Authorize [platformI$tformIdAndOs=2533274802474744|360, userRegion=America|360
got the same thing in terms of a u: number but the issue is I need to remove duplicates and just leave one and the file has multiple duplicates of different u: numbers and it's 14,000 lines long. can anyone tell me if I can use awk? sed? or sort for something like this to? removing lines that have a certain string in there that's a duplicate.
View 4 Replies
View Related
Jan 3, 2010
About finding the fastest booting operating system is out there.
I'm especially interested in Ubuntu Netbook Remix and Intel Moblin, and when my internet comes back tomorrow, xPud. I'm kinda freaked at Moblin though because there isn't an option to split the hard drive to account for its space, and even if there were, I'm freaked that a GRUB won't show up Ubuntu or even Windows 7
My requirements:
1. Boots up in 5-15 seconds on 1.3GHz processor/4GB RAM or within 10 seconds on a netbook which has 1.6GHz Atom and 1GB RAM
2. Has to have a good-looking window manager (so a customised Linux distro with something like Fluxbox/Blackbox is out). Something like what's in netbook designed OS's are good
3. Has to actually be able to run good on laptops that aren't netbooks, for I'm hoping to run the OS on proper laptops too
4. Can be propiertary, though open-source and free is good too and preferable
5. Has to have a GRUB so I can switch between Ubuntu/Windows 7/whatever fast-booting OS it might be or at least an easy way to switch between the 3. More preferable is that it comes as an .exe that can be installed inside Windows, like xPud
View 9 Replies
View Related
Mar 19, 2011
I have just got an SSD (Kingston SSDNow 100v 64Gib)It supports TRIM, and is definitely one of the better ones available.I am asserting here that the "limited number of writes" problem is a myth, so I'm not looking for an answer to that.My question is, what filesystem will help me get the best performance out of my SSD? Bear in mind SSDs excel at random access time, but sequential file performance is meh
View 2 Replies
View Related
Sep 30, 2010
The stock one seems ok but is it the best?
View 5 Replies
View Related