logo
down
shadow

How to find all files on a *NIX server containing a certain string


How to find all files on a *NIX server containing a certain string

Content Index :

How to find all files on a *NIX server containing a certain string
Tag : linux , By : George H.
Date : January 12 2021, 08:33 AM

around this issue grep can recurse on a given directory if you use the -r or -R flag. The second one will follow all symbolic links. The rgrep is a shortcut for grep -r.
grep -nsF 'myname@abc.com' -R /htdocs

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Visual SVN Server security hole - attempts in trying to find files on our server


Tag : development , By : Saul
Date : March 29 2020, 07:55 AM
hop of those help? Use Windows Firewall to limit access to VisualSVN Server only from trusted networks.

using list.files() in R to find files that start with a specific string


Tag : r , By : simonth
Date : March 29 2020, 07:55 AM
hop of those help? I am using list.files() in r to read in files. However, the pattern= input will scan all files that contain that special string I am scanning for... , The pattern argument takes a regex, so you can use: pattern = "^CL"

Powershell - Find Files by Searching for String and Find/Replace Text


Tag : powershell , By : Angelo Giannatos
Date : March 29 2020, 07:55 AM
I wish this help you I'm learning powershell and trying to write a script that can find files in a directory by a string, and then do a find and replace on the files that are found. I want to store the file list as a variable and then loop through the files and replace specific strings. Here's my script and error, if you have any ideas it would be much appreciated. !
$GetFiles = Select-String -Path "C:\temp\*.xml" -Pattern "<cmn:BusinessName>ABC INC</cmn:BusinessName>"

foreach ($File in $GetFiles)
{
    $NewContent = Get-Content $File.Path | Foreach-Object { 
        $_ -replace "<cmn:FileNumber>0001234</cmn:FileReceiverNumber>", "<cmn:FileReceiverNumber>12345678</cmn:FileReceiverNumber>" `
           -replace "<cmn:DropIndicator>DROP</cmn:Indicator>", "<cmn:DropIndicator>DONTDROP</cmn:DropIndicator>"
    } 
    $NewContent | Set-Content $File.Path
}

Python, The fastest way to find string in multiple text files (some files are big)


Tag : development , By : marocchino
Date : March 29 2020, 07:55 AM
Does that help My files are generated from an oracle application and if there is an error, i log it and stop generation my files.
So i search my string by reading the files from the end, because the string am looking for is an Oracle error and is at the end of the files.
wrd = b'ORA-'
path = 'C:\path\to\files'    
     #### opens the path where all of .txt files are ####
    for f in os.listdir(path):
        if f.strip().endswith('.txt'):
            with open(os.path.join(path, f), 'r') as ofile:
                        try:
                            ofile.seek (0, 2)           # Seek a end of file
                            fsize = ofile.tell()        # Get Size
                            ofile.seek (max (fsize-1024, 0), 0) # Set pos a last n chars
                            lines = ofile.readlines()       # Read to end

                            lines = lines[-10:]    # Get last 10 lines
                            for line in lines:
                                if string in line:
                                    sendMail(.....)
                                    logging.error('There is an error {} in this file : {}'.format(line, f))
                                    sys.exit(0)
                        except IOError as e:
                            logging.error('Operation failed: {}'.format(e.strerror))
                            sys.exit(0)

Loop through files to find a string and send files containing that string to directories of the same name in bash


Tag : bash , By : firebasket
Date : March 29 2020, 07:55 AM
will be helpful for those in need Here is one way I figured out how to answer my own question above (with help and inspiration from user shellter above - thanks!):
ls -l | grep ^d | awk '{print $9}' > list_of_ligands.txt
mv list_of_ligands.txt ..

cd ..

while read NAME
do
        echo "$NAME"
        grep -l "$NAME" cert* | while read -r filename ; do
        cp $filename unique_ligands/$NAME
        cd unique_ligands/$NAME
        bash -c 'cat $(for((i=0;i<10000;i++)); do echo -n "cert-${i}.mol2 "; done) > zzz.txt 2> ./null'
        mv zzz.txt $NAME.mol2
        rm null
        rm cert*
        cd ../..
done
done < list_of_ligands.txt
Related Posts Related QUESTIONS :
  • How to prevent others for read /write on the file, while it is writing
  • Crontab error: "/tmp/crontab.calJpk":5: bad day-of-month
  • Getting syntax error using awk in parallel processing
  • cURL Bash save response body to file
  • The most clear and concise way to describe SSH commands in .gitlab-ci.yml
  • Read/write a big file randomly - mmap on every read/write?
  • Error while compiling for NodeMCU on Arduino IDE on Ubuntu
  • How to save the response body from cURL in a file when executing the command in a loop in a bash script?
  • why Linux system time adds and substracts one hour every 6 months?
  • How to exclude a specific file in scp linux shell command?
  • How to wrap lines within columns in Linux
  • How to store the output of a command that has already gone throgh pipeline
  • How to remove a certain type of files and directories from git add before commit?
  • How to check last modified date of a file in AIX using bash script?
  • What does the shell "${i%,v}" mean in run-parts.sh?
  • cat displays multi-line file content in a single line
  • No module named 'tensorflow.python.platform'
  • "Hash #" symbol cause the string to be split
  • What are the possible list of Linux bash shell injection commands?
  • curl is downloading the html rather than the actual zip file from gitlab
  • shell scripting "test " command
  • Socket incoming connections can not push_back elements concurrently to a globally defined std::vector
  • escaping complicated command line arguments in bash and ssh
  • Filtering files with the given range of inputin perl
  • Save cat command output to file
  • How to find all image tags of a running Docker container?
  • A working linux kernel + gem5 config for FS boot up in x86 SMP
  • Run script skipping files
  • How to trap exit (ctrl+c) signal in Makefile?
  • How to read a file using cat with Perl -e parameters?
  • why '~' tilde directory is created automatically in home directory on AWS EC2 instance
  • Remove the first capitalized word after a period
  • Adding a security feature to the ssh login
  • How to merge column output to the end of a row in the previous column?
  • How to write a custom device registration function for custom device such as RTC or ADC etc.?
  • Linux command to delete all the files older than the latest modified file/s
  • The sort command in linux does not work "correctly"
  • Atomic read and truncate of file in linux
  • Zip files within the directory without file extensions
  • How to prevent changes to the underlying file after mmap()-ing a file from being visible to my program?
  • OpenJDK9 Missing in Alpine Linux
  • Insert data into database using sqlldr in coldfusion
  • Can't realize alias/substitution function for my .bashrc
  • Can ack/ag/grep print function name?
  • How to extract log using bash script between a date / time and another
  • Homework: Trying to calculate Easter using arithmetic evaluations
  • How to loop through an output and format the result into a new report?
  • How to add verbosity option to control script output?
  • xm64 fills my processor resource in Linux Mageia 6
  • Measuring temperature while benchmarking on Linux
  • Grep using a regular expression and capturing using groups
  • Getopts default case bash script
  • C can I open a directory's files using open dir in an alphabetical order?
  • Get a tag value in multi line XML using shell script
  • Errors while execute 'make' command, debian
  • How to speed up grep/awk command?
  • Why does calling the C abort() function from an x86_64 assembly function lead to segmentation fault (SIGSEGV) instead of
  • Passing commandline argument to qml
  • Bash command with pipe not working in crontab
  • DBD-Oracle (1.74 or 1.76) with oracle instantclient 11.2 on win10 wsl ubuntu
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com