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


ADVERTISEMENT

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 :: 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 :: Count The Number Of Lines In All Files In This Directory?

Jul 5, 2011

I want to count the lines of all files in this directory and all its subdirectories, but exclude directories "public", "modules", and "templates".

View 2 Replies View Related

Programming :: Perl Regex Not Matching Across Multiple Lines Despite Ms Flags / Fix It?

Aug 16, 2010

I have written a regular expression (tested in regexpal and regextester alpha something) with which I want to replace something like code...

but it only matches functions which occupy one line only, despite my tests showing multiple line matching in javascript testers online and using the m and s flags (which should make it multi line no?)

View 14 Replies View Related

Debian :: [Exim4] Remove Header Lines Matching Received Client Ip?

Oct 14, 2009

Using exim4 only for sending email SMTP

I'd like to use Exim to remove the line header:
Received: from [111.111.111.111]
by HOSTNAME with esmtp (Exim 4.69)

what setting i should use and where should i put it in the exim4 configuration file, transport, router etc.

View 1 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 :: 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 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

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 :: 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 :: Thick Black Lines Sometimes Appear On Printing / Avoid Them?

Feb 22, 2010

Operating System: Ubuntu 9.04
Printer: LaserJet CM1312 MFP

I have an intermittent printing issue that results in part of a printed page containing a horizontal line that spans over two lines. The line is mostly black, with the occasional small break where there seem to be printed multiple characters printed over each other.

Sometimes I print and I do not get this issue. Other times I can print 60+ pages and it happens, while sometimes I get it on a single page being printed.

I'm not sure if this is a driver, printer or cable issue. We've used it through CUPS and we've used a print hub to convert the USB to a network accessible printer to see if that made any difference but it did not.

I have a feeling this has something to do with the print job data corruption.

View 3 Replies View Related

Software :: Printing Specific Lines Of File Using Script

May 19, 2009

I have text file with say 1000 lines.And I want to display lines numbered 100, 203 and 297 using a script/ command.How can I do this ?I can print a particular line using:sed -n '100p' file1 (where file1 is input file).

View 6 Replies View Related

Ubuntu :: When Drag The File To Install It Again It Says Something Along The Lines Of It Cannot Copy A Directory Over A Directory?

Feb 19, 2010

I downloaded a mouse theme form gnome look and installed it in the themes. But it has not appeared in the pointer themes section in custimation even though it said that it is installed correctly.When I drag the file to install it again it says something along the lines of it cannot copy a directory over a directory.Where can I find where the mouse/pointer theme is located and delete it. I have searched filesystem, google and these forums and not had any luck yet.

View 1 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

General :: Substituting Lines In Files Without Need To Escape?

Jan 17, 2011

Usually when I need to replace some lines in a file, the first tool that comes to mind is sed -i:

sed -i 's|tool:.*|tool: some-tool|'

However, it's inconvenient when there are . characters in the replacement string:

sed -i 's|host:.*|host: 127.0.0.1|' Is there a better tool for this case?

View 1 Replies View Related

General :: Comparing Lines In 2 Text Files?

Nov 5, 2010

Is there a way, besides writing a PERL program, to read each line one by one in file A and tell if this line also exists in file B? Can this be done via a shell script?

View 6 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

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

General :: Perform A Long Directory Listing Of All Files In The /bin Directory That Have Exactly Three Characters In Their Name?

Jan 18, 2010

How do you perform a long directory listing of all files in the /bin directory that have exactly three characters in their name?

View 1 Replies View Related

General :: Script To Append Lines To Multiple Files?

Aug 22, 2009

eed to make a script to append a line to the bottom of multiple files (only certain files, but 100's spread over directories).Doing a find replace inside multiple files is easy, I use the followingfind /base/dir -name "*.txt" -exec perl -pi -w -e 's/FIND/REPLACE/g;' {} ;So I tried doing the followingfind /base/dir -name "*.txt" -exec echo "Append this" >> {} ;However this just appends all the text into a file called "{}". Whereas {} should be replaced with each file that's found.

View 1 Replies View Related

General :: Compare 2 Text Files And Change Lines?

Jul 21, 2011

in the shell. how do i compare 2 text files and change matching lines in one of the files ?

example:
cat file_1.txt
line_1

[code]...

View 6 Replies View Related

General :: Files Created In A Directory Owned By Directory Group?

Jan 29, 2010

Is there a way, on Linux, to cause all new files created in a directory to be owned by the directory's group instead of the creating user's group?

View 2 Replies View Related

General :: Cronjob Directory / Send An Email If Directory Contains More Than Ten Files?

Oct 13, 2010

I want to run a cronjob every 15 minutes that checks a directory for files. If the directory contains more than ten files I want it to send an email to me.

All I have is this...

*/15 * * * * ls -l | wc -l | [filename] | mail -s "This is just a test" [email address]

I would rather not write a bash script. Is there an easier way to do this? I was looking into some commands like find and grep.

View 6 Replies View Related

General :: Find Directory Older Than X And Mv Directory With Sub Files Command?

Jul 13, 2011

I'm quite new to linux but I have configured a simple ftp server and it's working great. I have a FTP-Shared folder with upload and download subfolders. Under upload's and download's I have identical category subfolders like mp3's, movies, software etc. in both. As the guy's upload, I would like to create a line crontab where I can move all the content under /FTP-Shared/upload/mp3/* older than 14 day's to FTP-Shared/downloads/mp3/ recursively (Like in cp command), but the timestamp must be searched on the first directory and not sub files example: /mp3/Club Dance/CD1/Hallo world.mp3This is how far I got:[root@clients ~]# /usr/bin/find /FTP_Shared/upload/Mp3s/ -depth -mindepth 1 -mtime +14 -type d -exec mv -f {} /FTP_Shared/download/Mp3s/ ;This command moves the directory and files, but it is not recursively

View 4 Replies View Related

Programming :: Rename Files Matching A List?

Jul 12, 2009

Is there a way, preferably in python or BASH, to rename files from a list? for instance, track1.mp3, track2.mp3 should be renamed to the names stored in a file listing song names. I have tried to loop a variable through directory listing and renamed them, only to find that filenames with spaces can't be assigned to a variable as a whole. To solve the problem above, I have tried the read command in BASH, which enables the program reading line by line from a list. However, It was failed to pipe the results from directory listing to the read command.

View 14 Replies View Related

General :: Count Total Number Of Lines Of Found Files?

Mar 20, 2011

I'm running a find. -name pattern to find some files, and I'd like to elegantly get the total number of lines in these files. How can I achieve that?

View 4 Replies View Related

General :: Splitting Text Files Into Parts With 2000 Lines

Sep 7, 2010

I am facing a problem while splitting a text file, I need to split a file into some parts and each split file should have 2000 lines, when I do it through "split" command the mother file is kept intact but as per my requirement I need to cut mother file into some parts thus it should not be kept intact.

Example:
file size
motherfile.txt 5000 lines.
after split
motherfile.txt 2000 lines.
childfile1.txt 2000 lines.
childfile2.txt 1000 lines.

View 7 Replies View Related







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