General :: "Argument List Too Long" - Deleting Files Based On Grep?

Jan 28, 2011

I've got a directory with thousands of files and I want to delete those that contain specific text.When I try:Code: ls | grep -l "specific text" * | xargs rm I get the error: Code: /bin/grep: Argument list too long Is there an easy way to get around this without having to move files into seperate folders and processing them in batches? I found an article on getting around this problem, but I'm kind of new to Linux and don't know how to apply this to my specific problem.

View 3 Replies


ADVERTISEMENT

Ubuntu :: Large Number Of Files To Count - Argument List Too Long

May 28, 2011

I have the standard problem of trying to count a large number of files in a directory (>100k)

I have tried: ls ~/user/images/* -l | wc -l and find ~/user/images/* -maxdepth 1 -type f | wc -l

In both cases, I get the argument list too long error message.

I have tried using xargs but I can't seem to get it to work right.

The command

returns a valid answer but it includes all the subdirectories in the file count.

View 4 Replies View Related

General :: Find Argument List Too Long?

May 12, 2011

I want to search in many many files for a string.

I used find /archive/* -print0 | xargs -0 grep 'robert' -sl

Is there a simple method to do it ?

View 2 Replies View Related

General :: Using Find With File Name And Mtime To Remove Files Gets Arg List Too Long Error?

Dec 25, 2009

I need to delete all *.trc files that are older than 30 days and I am getting a "Argument list too long" error. There are other files that should not be deleted which is why I am using the "*.trc" and newer files need to be kept as well. I have seen other postings but they do not cover both of the conditions. Below are 2 of the many attempts at doing this but I cannot get this to work.

find *.trc -mtime +31 -print| xargs rm -f {}
find *.trc -mtime +31 -print -exec rm -f {} ;

View 3 Replies View Related

General :: List Files Based On Matching Only Part Of Their Filename?

Sep 13, 2011

I have many files in a folder for example

Kiran.txt
Kiran1.txt
Kiran221.txt
Kiran144.txt
Time.csv

[Code]...

From this directory, I want to know how I could use grep to display files based on part of their filename - for example those starting with "Account" or those ending in ".sh".

View 4 Replies View Related

Ubuntu :: Deleting Files Based On Number Created (or In Folder?)

Jul 21, 2011

I'm dipping my toes into some bash scripting and was wondering if there was a way to delete a file not based on how old it is, but rather how many other files are currently in the folder... or something to that effect....

What I'm doing is creating a script to back up a folder nightly. I'd like to keep a maximum of 3 backups. However in case the script for some reason fails to run one night (computer turned off possibly) I don't want to set the condition for deletion to be the date.

I know that if I run:

Code:
find /path/to/files* -mtime +3 -exec rm {} ;
that it will delete everything older than three days. -atime and -ctime don't seem to be what I"m looking for... is there another command I can use to achieve what I"m trying to?

View 5 Replies View Related

General :: Run Ps Fax|grep - Strange Grepped Process List

Sep 1, 2011

When I run ps fax|grep grep it shows one process like:

How is that possible?

View 1 Replies View Related

General :: Sending Find Results To File - List Too Long

Aug 12, 2010

I'm trying to do a
find /photos/* -type f -mtime +365
to find all my pictures that are over a year old, but I keep getting argument list too long. How can I view what all the results are, even if it just dumps it to a file that I have to open?

View 12 Replies View Related

Programming :: HUGE Files - Compare A List Of Patterns From One File And Grep Them Against Another File And Print Out Only The Unique Patterns?

Aug 13, 2010

I am trying to compare a list of patterns from one file and grep them against another file and print out only the unique patterns. Unfortunately these files are so large that they have yet to run to completion. Here's the command that I used:

Code: grep -L -f file_one.txt file_two.txt > output.output Here's some example data:

Code:
>FQ4HLCS01BMR4N
>FQ4HLCS01BZNV6
>FQ4HLCS01B40PB
>FQ4HLCS01BT43K
>FQ4HLCS01CB736
>FQ4HLCS01BU3UM
>FQ4HLCS01BBIFQ

how to increase efficiency or use another command?

View 14 Replies View Related

General :: MV - Missing File Argument (Moving Files Within LAN)

Feb 1, 2010

Objective: To move or backup all the 30 days old files to the other server within LAN. I have tried testing it first within the server by performing below commands:
find /usr/test1/* -mtime +30 -exec mv {} /usr/test2/ ;
But I'm getting "mv: missing file argument" error when I try this.

View 1 Replies View Related

Programming :: [bash] Option Followed By Argument List?

Feb 6, 2010

I'd like to pass the following arguments to a bash script in any order:

Code:
myscript -l <country> -r <file1> <file2> ... -o

I read the argument list in a switch shift loop. I figured out how to read the filelist but only if -f is the last option.

how to position the file list anywhere in the argument list?

View 5 Replies View Related

Programming :: Grep And Pull The IP Based On The Request String?

May 5, 2010

in the access logs i have this:

Code:
IP.IP.IP.IP - - [01/May/2010:11:21:10 -0400] "BIG STRING" 414 250
how can i grep and pull the IP based on the request string?

View 7 Replies View Related

General :: View List Of Updated Packages After Apt-upgrade On Debian-based Systems?

May 15, 2010

I just did an update on my Debian system and it was very long. I'd like to know now, after the upgrades have already been applied, which packages were upgraded and which were not.

View 2 Replies View Related

General :: Deleting Iframes From Files

Apr 25, 2009

my website was recently infected with this stupid malware lotultimatebet .cn...there is a hidden iframe on almost all the 6000 pages of my site.can you please advise, if it is possible for me to remove this line from all pages by executing some command?

View 1 Replies View Related

General :: Deleting All Files From Directory Except For Two

Nov 25, 2010

I'm writing a Perl script which performs linux commands.I have a directory with a load of files.

Code:exec_cmd('rm $(ls * | grep -v file1)');
This command will delete all except for file1. How can I modify this to delete all files except for file1 & file2?

View 2 Replies View Related

General :: Deleting Files By Date

Nov 5, 2009

I had a program run riot and it has created hundreds of spurious files in one directory. Fortunately they are all dated 4th November so are easily identified. What bash command can I use from the console to delete them all?

View 2 Replies View Related

General :: Rsync Not Deleting Files On Target

Sep 8, 2010

I'm using the command below to sync two directories. Problem is insted of deleting the files on the target directory it simply appends a ~ character at the end of the file name. Not sure why this is happening?I'd like to have all deletes on the source replicated on target.

View 2 Replies View Related

General :: Deleting Files Older Than 1 Hours

Sep 8, 2009

on my site now I'm using cache and need me cron script that will delete files older than 1 hour I have feature in my kloxo control panel just need me the command .

View 2 Replies View Related

General :: Deleting Lines From Text Files

Sep 17, 2009

Is there anyway to delete certain paragraphs within a text file and then insert the paragraph into another text file.I just cannot figure out how to remove the specific lines from the file and then insert them into another file at a certain line within that new file. Thanks again

View 10 Replies View Related

General :: How To Delete All Files In Directory Without Deleting?

Feb 9, 2010

I know that rm -i will prompt wether you want to delete each file.But rm -i -r will prompt for each file in each subdirectory recursively. How to make it prompt just for the directory itself, and then delete its contents without asking?How to delete all the files in a directory without deleting . and ..?How to recursively delete all tilde files in a directory?How to GUI file managers delete files to Trash? Where is this "Trash" located? Can you delete to trash in the command line?

View 14 Replies View Related

General :: How Long Are Files Kept In /var/tmp/, And How To Use The Directory

Jul 26, 2010

I'm always hesitant to use /var/tmp/, because I never quite know exactly how long the files are kept there for, or even what the directory is used for. What determines when a file gets removed from /var/tmp/, and how is the directory intended to be used?

View 2 Replies View Related

General :: Get Files That Match ALL Patterns (using Grep)?

Jun 9, 2010

I want to traverse a directory and get a list of files that contain a set of patterns. I assumed I could use grep for this, but I having trouble getting grep to only return files that match ALL patterns. Here's what I've come up with so far:

Code:

grep --recursive --file=searchpatterns.txt --files-with-matches somedirectory/*

However, this gives me a list of files that match ANY of the patterns in the searchpatterns.txt file. I want to match ALL of the patterns. I've looked through the man page, but can't find anything that allows me to change the "OR" to "AND" for multiple patterns.

View 5 Replies View Related

General :: Searching For PHP Files With Find And Grep

Nov 2, 2010

I am looking for all the files that contain the text string 'moo.sql'. I ran the following:

find . -name '*.php' | grep -lir 'moo.sql' *

Unfortunately it seems to return non-php files in addition to php files. I thought the find portion of this would filter the file names so grep would only search php files.

View 3 Replies View Related

General :: Making Grep Find Files Containing '$'

Dec 5, 2010

I want to find files containing the "$" char (ascii 0x24). 'Grep -irl $ *' would output the names of every file in path *, of course, because it means end of line (EOL). So giving grep the string "$" won't do. So I tried 'grep -irl $ *'. But this doesn't work either and I do not understand why. Am I not escaping the dollar sign? grep should interpret it literally. Neither 'grep -irl "$" *' will work. Fortunately, there's LQ, besides grep's man page.

View 9 Replies View Related

General :: Deleting Files On USB - Input / Output Error

May 4, 2009

[root@localhost media]# ls UMESH
[root@localhost media]# cd UMESH/
[root@localhost UMESH]# ll
ls: cannot access ejb: Input/output error
total 0 d? ejb
[root@localhost UMESH]# rm -rf ejb
rm: cannot remove 'ejb': Input/output error
[root@localhost UMESH]# ll
ls: cannot access ejb: Input/output error
total 0 d? ejb
[root@localhost UMESH]#

The privileges for root for UMESH are as below:
[root@localhost media]# ll
total 4
drwxr-xr-x 3 vickey root 4096 1970-01-01 05:30 UMESH
[root@localhost media]#

Also I can't even paste a file in the USB.

View 7 Replies View Related

General :: Rsync Deleting Files From Destination Directory?

Jul 14, 2011

We have an rsync cron job set up to mirror all the files in a "..dashtdocsdocs" folder to the same folder on another server. It copies all the files over correctly and deletes any files in the "docs" directory that aren't in the sending directory, but it also deletes any files we put in the target directory's parent folder (..dashtdocs or other subfolders like ..dashtdocsimages) even though they've been excluded in the .rsync-filter file.

Here's our current rsync .sh:

/usr/local/bin/rsync --stats -qPzrtpl --delete --password-file=/var/run/.appprodrsync --log-file=/export/home
/webuser/logs/rsync-extranet-log -FF /export/home/ appprodrsync@appprod::dprweb_extranet/ > /export/home/webuser/logs/rsync-extranet-output 2>&1

[code]....

So for example server A has ..dashtdocsdocs and ..dashtdocsimages. Server B has ..dashtdocsdocs but if I manually copy the images folder over to ..dashtdocsimages, the images folder gets deleted from the target directory every time rsync runs.

A: ..dashtdocsdocs
..dashtdocsimages
B: ..dashtdocsdocs
..dashtdocsimages (<-- gets deleted everytime rsync runs)

I'd like to keep just the docs directory synched and update other folders manually, but they keep getting deleted. It looks to me like it's running a delete-excluded option, but that option wasn't used.

View 2 Replies View Related

General :: 'all Files' Switch For Grep - Including 'hidden'?

Jun 14, 2010

If I type 'grep alias .bashrc' a whole load of stuff comes up. However, if I type 'grep alias *' nothing comes up. Is there some switch for including 'hidden' files - like the -a switch for ls?

View 2 Replies View Related

General :: Awk / Grep Or Sed - Find And Replace Recursively From Files

Feb 12, 2010

I am new to linux as well as awk, grep or sed. I need a find and replace command single liner or script that loops trough input file (file1) and find the particular input in file2 and add "!" in front of the found string.

Example:
input file: file1
g+h=o+p
a+b=c+d
file2 (file that need to look for)
a+b=c+d1e105
x+y=z+s5e105
g+h=o+pabcdefg
t+r=w+qxvyderf

Output file (file3 should look like this)
!a+b=c+d1e105
x+y=z+s5e105
!g+h=o+pabcdefg
t+r=w+qxvyderf

I have tried many awk and sed method of find and replce but it did not work the way I wanted. This is mainly due to my lack of experience in awk and sed. The program should loop trough file1 and find in file2 and output in file3 for the 1st (g+h=o+p) set then repeat the same process again for set 2 (a+b=c+d).

View 14 Replies View Related

General :: Grep -- Finding Files That Contain Two Separate Strings?

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

General :: Manually Remove .vdi Files Left Over After Deleting VirtualBox?

Oct 24, 2010

I have a question, that may sound silly. I have removed VirtualBox from my Ubuntu install. But the .VirtualBox folder is still existing with a virtual drive of nearly 10 GB. Can I manually remove the folder .VirtualBox with rm -rf without any unwanted side effects?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved