General :: Delete Matching Files In All Subdirectories?

Feb 22, 2010

How can I remove all .swp files in all of my subdirectories under Linux?

View 4 Replies


ADVERTISEMENT

General :: Find Files In Subdirectories And Copy Them To Another Directory With The Same Subdirectories?

Nov 18, 2010

This question is very similar to this one except that I want to maintain the file's original subdirectories.

For example if I had

/temp/a/a.txt
/temp/a/a.jpg
/temp/a/b.txt
/temp/b/c.txt
/temp/d/d.txt
/temp/d/d.jpg
/temp/d/e.txt
/temp/f.txt

[Code]...

View 2 Replies View Related

General :: Grep Or Sed To Delete Matching Pattern?

Jul 7, 2011

How can I use grep -Ev "pattern" not only to delete the matching "pattern" but to edit and save the file permanently as well

View 2 Replies View Related

General :: List/find All Regular Files In All Subdirectories Excluding Binary Files

Oct 5, 2010

I know I can do find . -type f, but that includes binary file and I couldn't find a way to exclude them with find

View 4 Replies View Related

General :: Recursively Remove Subdirectories And Files But Not The First Parent Directory?

Feb 11, 2010

I'm able to use the following to remove the target directory and recursively all of its subdirectories and contents. find '/target/directory/' -type d -name '*' -print0 | xargs -0 rm -rf

However, I do not want the target directory to be removed. How can I remove just the files in the target, the subdirectories, and their contents?

View 4 Replies View Related

Programming :: Sed: Delete Last Line Matching A Pattern?

Mar 27, 2011

I have a question about sed programming, actually a one-liner for which I cannot find a solution, right now. I need to delete a line matching a specific pattern only if it is the last line. In practice, I would put together the following:

Code:
#
# This deletes the last line of a file

[code]...

View 5 Replies View Related

General :: Listing Files Using Pattern Matching

Mar 13, 2011

I have a requirement to list files using find command My folder contains below list of files with out extention.I have a requirement to exclude only ABC.123.* type files and list others. Even though files having MNO contains this pattern i should not exclude. Even if file ends with .txt or .doc it should not be excluded. That is ABC.123.1234.txt should not be excluded.But I am not getting what is required. Can any one please let me know if I am doing wrong any where. As per my requirement I cannot use grep, -regex, or -regex attributes to find command.

View 7 Replies View Related

General :: Copy All Files Matching Pattern From SRC To DST

Jul 19, 2011

If I wanted to copy all *.so files from src to dst I'd do:
cp src/*.so dst
However, I want to copy all *.so files from src and it's subdirs into dst.

View 2 Replies View Related

General :: Cross Reference Matching Between Files?

Oct 18, 2009

I'm trying to do something very basic in bash. It's a kind of cross-reference matching between 2 files. I have a file1.txt. It's like this:

Code:

item1
item3
item4
...

I Have a file2.txt. It's like this:

Code:

item1 "Properties of item1"
item2 "Properties of item2"
item3 "Properties of item3"
item4 "Properties of item4"
item5 "Properties of item5"
...

My goal is to print out the lines in file2 that contains lines present in file1. I do:

Code:

for i in $(cat file1.txt); do grep $i file2.txt; done but I get no output. Will someone please tell me where am I mistaking?

View 3 Replies View Related

Ubuntu :: Bash - Delete First File Matching Regex?

Mar 27, 2011

In a bash shell script, I want to do something like this:

Code:
if [[ $(ls -ld /some/dir/foo_* | wc -l) -gt 4 ]]; then
rm -rf first_match_of /some/dir/foo_*

[code]....

View 6 Replies View Related

Programming :: Delete Line In File Matching String?

Jan 26, 2010

Quote:Originally Posted by topcatI would like to know how i can write a shell script to delete a line if a particular pattern exists?E.g. I have a text file with multiple lines. Say 1000s. in the following pattern.

username@email.com:149.0.3.4:1
username1@email.com:149.0.3.4:1
username1@email.net:149.0.3.4:1
username1@email.edu:149.0.3.4:1

If the patternusername@email.com exists then the line "username@email.com:149.0.3.4:1 should be deleted from the file.I have a very similar question but I need to delete one line in a file which matches one very precise instance of a string only. Let's assume I have a file composed of thousands of lines and let's call the file chap-secrets. Let's take the following sample entries:

Code:
#USERNAME SERVER PASSWORD IP
pp pptpd blahblah *

[code]....

View 7 Replies View Related

General :: How To Get List Of Files Not Matching Patterns In Bash

May 4, 2011

I have a file with joker character patterns:
./include/*
./src/*
etc.
From the current directory I would like to recursively get the list of files that do not match these patterns.

View 2 Replies View Related

General :: Copy Wildcard Files From Directories For Matching

Feb 11, 2011

I have 2 massive duplicate dirs of the same format as below:
dir1
subdir1
file1
subdir2
file1
subdir3
file1
...

Dir2 is the same, but it has some newer files of the same name. I want to copy all file1's from Dir2 to the same name and folders in dir1. So basically something like:
cp -pr bkpDir1/*/*-big.gif Dir2/*/*-big.gif

This works for singular cases:
cp -pr bkpDir1/uniquesubdir/*-big.gif Dir2/uniquesubdir/*-big.gif

But not for wildcards:
cp -pr bkpDir1/subdir*/*-big.gif Dir2/subdir*/*-big.gif

Anyway the aim is to do the first cp above, I have tried a few options using find. In trying to show an example stumbled upon a way that worked, while in dir2:
find */*-big.gif | xargs -i cp -rp {} ../dir1/{}
Sure there are better ways also...

View 1 Replies View Related

General :: Recursive Searching Files In Directory Matching Given Name?

Apr 16, 2010

I am writing a shell script that finds all files named <myFile> in a directory <dir> or any of its subdirectories, recursively. I also need to take care of symbolic links that may form cycles, to avoid infinite loops. I am not supposed to use find command for the same

I started writing the code but got stuck. I thought using recursion may be a smart way, but its not working.

Code:
#!/bin/sh
findFiles()
{
thisDIR=$1
#cd $thisDIR
code....

View 5 Replies View Related

General :: Command Line - Automating A Task - Copy All Subdirectories And Files From One Directory To Another

Jun 10, 2010

I need to copy all subdirectories and files from one directory to another ever 5 minutes or so, with the old data automatically being overwritten with the new data. I'd also like this to run at startup. Is there any way this can be done? If so, what program would I need to schedule the automation and what is the command line I would need.

View 2 Replies View Related

General :: Printing Matching Lines When Greping All Files In A Directory

Apr 3, 2010

I'm searching within Java files for some occurrence of a phrase:

find . -name '*.java' | xargs grep -l 'string'

How do I change this command to print to the shell all of the lines which contain a match?

View 4 Replies View Related

General :: Compare Directory Structure Without Matching Data In Files

Jul 22, 2010

What is the best and simplest way to compare two directory structures without actually comparing the data in files. This works fine:
diff -qr dir1 dir2
But it's really slow because it's comparing files too. Is there a switch for diff or another simple cli tool to do this?

View 4 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 :: Command With The -r Option To Compare A Large Number Of Files And Files In Subdirectories

Jun 16, 2011

I am using the diff command with the -r option, to compare a large number of files and files in subdirectories. My main interest is to find out which files have been changed, and not what the actual changes are, and since a lot of files has been changed, it would be a lot easier to view the file names only. Is there and option for diff that might do this, or does there exist a similar tool/command that could do the job?

View 1 Replies View Related

General :: Rename Multiple Files In Multiple Directories/subdirectories Recursively?

Aug 23, 2010

I am to rename all the files within a directory (which contains multiple subdirectories) recursively without invalid characters.

I tried the coding posted above.

find . -type f -printf '%p
' | while read file; do
oldfile=$(basename "$file")
newfile=$(echo "$oldfile" | sed 's/[^A-Za-z0-9_.]/_/g')
if [ ! "$newfile" == "$oldfile" ]; then
echo mv "$file" "${file%$oldfile}$newfile"
code....

but I get an error on both of them stating "find: bad option -printf find: [-H | -L] path-list predicate-list"

View 9 Replies View Related

General :: Search In "/" And All Subdirectories - All Files Greater Than 30 MB

Feb 21, 2010

I need to search in "/" and all subdirectories, all files greather than 30 MB.

View 5 Replies View Related

Slackware :: Move Files From Within Many Subdirectories To Another One?

Jun 25, 2011

I have a large directory tree with my ebooks and some of these files are zipped. I would like to move all of the zip files to another one so I can manipulate them. Since they are all scattered inside the tree, I would like to do it quickly and painfully with CLI. How should I proceed?

[code]...

View 10 Replies View Related

General :: Wget / Delete Files / Getting Bunch Of Filefolders, But No Files, Ex."cccamp07-de-1845?

Oct 11, 2010

I am trying to dl the files located here: http://good.net/dl/bd/CCCamp-2007/video/m4v/ using wget.

Now when I use the command wget -r -A .m4v http://good.net/dl/bd/CCCamp-2007/video/m4v/

I get the just a bunch of filefolders, but no files, ex."cccamp07-de-1845-Freifunk_und_Recht.m4v" but its a folder.

View 4 Replies View Related

General :: Find/grep/wc Command To Find Matching Files - Print Filename And Word Count?

Sep 11, 2009

I am trying to do a find/grep/wc command to find matching files, print the filename and then the word count of a specific pattern per file. Here is my best (non-working) attempt so far:

wc `find . ( -name "*.as" -o -name "*.mxml" ) -exec grep -H HeightResizableList {}` ;

View 10 Replies View Related

Ubuntu :: Bash To Sort Files Into Subdirectories?

Sep 4, 2010

i currently have hundreds of files all in a single directory. What I would like to do is create 8 subdirectories and move the files into the subdirectories based on the first character of the file name. Ideally, the script would omit any 'the' or 'a' and use the second word for filing purposes. No filenames have spaces. Instead they use periodsThe subdirectories will be:

0-9
a-d
e-h

[code]...

View 2 Replies View Related

Programming :: Search A String In The Files In The Subdirectories?

Mar 10, 2011

How can I search for a string (for example, a constant) in all the (.cpp) files in the current direcotire and subdiretories.

View 4 Replies View Related

General :: Possible To Delete All The Files Including System Files As Root?

Sep 21, 2010

If I am logged in as root in a linux system and I run command rm -rf on / folder, should it remove all the files? also the kernel?

View 4 Replies View Related

Software :: Read Files In Subdirectories On Encrypted Drive

Dec 18, 2010

Two machines -- both 64-bit, both the latest Truecrypt installed, one Windows, one Linux. I created encrypted pendrive (using partition mode; not file-partition on regular partition) with FAT system on it. I copied several files/directories there -- using Windows. Then I unmounted it, mounted in Linux, but when I checked if everything is OK, it appeared that only the highest level of file hierarchy is visible -- i.e. only files and directories at mount point. Directories are seen as empty (in fact they are NOT empty). When I unmount pendrive and mount it again on Windows, all files/subdirectories are visible again. It is not an issue with older version of TC on Linux, because the version is the same. The question: how to make files in subdirectories visible on Linux?

[code]...

View 5 Replies View Related

Slackware :: Rsync Exclude Directory With All Subdirectories And Files

Dec 26, 2010

In reading the rsync man page and browsing a lot of websites, I ended up a bit confused, or maybe it was just too much eggnog. Anyway, to exclude a directory "videos" with everything in it, which is /home/user1/camera/videos and I'm rsyncing the whole user1 directory to an external drive

[code]...

View 1 Replies View Related

Programming :: Matching Two Tables Of Non-matching Sizes?

Mar 2, 2011

I have two table files with x (1st column) ,y (2nd column) coordinates and intensity (3rd column). I need to match these two tables and divide the intensities at the consecutive coordinates on the 3rd column. The problem is the size of the tables are not same and I want to ignore the lines if they are not in one of the other file.

Here is Table 1:

Code:
-7.500-30.00013.006
-7.500-22.50037.952
-7.500-15.00060.962
-7.500-7.50040.922
-7.5000.00014.348
code....

View 3 Replies View Related







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