General :: Command To Find A Specific Word In Directories And Subdirectories?

Jun 7, 2010

tell me the command used to find a specific word in directories and sub-directories in linux?

View 4 Replies


ADVERTISEMENT

General :: Recursively Find A .doc File That Contains A Specific Word?

Aug 31, 2011

I'm using bash under Ubuntu.Currently this works well for the current directory:catdoc *.doc | grep "specificword" But I have lots of subdirectories with .doc files.How can I search for, let's say, "specificword" recursively?

View 2 Replies View Related

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 :: 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 :: Command For Listing Files/dirs Recursively Of Specific Directories?

Jul 22, 2011

suppose in my current directory, I have 50 sub-directories. Now, I am interested only in about 20 of those sub-directories (whose names match a pattern). I would like to recursively list the contents of these 20 sub-directories. How do I do that ? I would like to do this in Solaris 10 and Linux(RHEL 5.x).

View 3 Replies View Related

General :: Find A File In Directories Without Using Find Command?

Aug 3, 2010

am new to linux and trying to find a file in sub directories using find command as:find .-name *.jpg -type fBut I am unable to get the result as find command is not permitted by the server administrator.Is there any way to find files without using find command.

View 14 Replies View Related

Software :: Using Find To Only Search Specific Directories?

Jan 9, 2010

how the "-prune" option works. I've searched quite a bit on line, and as far as I can tell, "-prune" works exactly the opposite as it says.

I'm using Apt-proxy, and I want to scan through the folders, and find files that end with "*.bz2" The problem is that the search takes a while because of all the "*.deb" files. Fortunately, they're stored in their own folder:

/var/cache/apt-proxy/ubuntu
/var/cache/apt-proxy/ubuntu-security
/var/cache/apt-proxy/partner
each have two folders:

[Code]....

View 5 Replies View Related

General :: Get A Shell Script To Loop Through A Number Of Directories And Subdirectories?

Jul 27, 2010

I'm looking to get a shell script to loop through a number of directories and subdirectories,looking for files that contain a particular substring, and renaming the file by replacing the search string with a different substring. For example if you had a directory full of folders that contained digital photos (along with various other files which would need to remain unaffected), and the intent was to remove the "DSC_" prefix from several thousand files buried within. I've whipped up a rather long-winded solution that works well for this purpose but chokes on directory names with spaces. I am reasonably sure there's a 2 or 3-liner that would accomplish this exact same task.

function investigate
{
path=$1
for file in `ls $1`
#for file in *

[code]....

View 1 Replies View Related

General :: Search Word And Delete Only The Word And The Line Using Sed Command?

Jun 28, 2011

Want to search for ~ and delete it as well as to append the entire line to the above line. For Ex:

1111xxxx date Sandy area is ~around this area.3222xxx date There seems to ~left side of map, the colours are accurate (showing green areas)Even if I ~zoom in, the green parks, xxx3258 date The dammed up
~away, the "other" body of water varies ~blackNatural gas leaching.

IT MUST LOOK LIKE:

1111xxxx date Sandy area is around this area. 3222xxx date There seems to left side of map, the colours are accurate (showing green areas)Even if I zoom in, the green parks, xxx3258 date The dammed up away, the "other" body of water varies blackNatural gas leaching.

View 4 Replies View Related

General :: Copy All .jpg Images In Subdirectories To A Specific Directory?

Aug 5, 2010

I have .jpg files in many subdirectories from where I need to copy all the images from all the sub directories and paste them to a specific directory.I have used `cp -rf *.jpg media/sik/` which only copies the .jpg files of the directory in which I was working.

View 5 Replies View Related

Ubuntu :: A Command To Find A Command With A Specific Substring?

Mar 19, 2011

want to know if Ubuntu provides a command to search for a command having a specific word.e.g.If I know a command contains editor as a substring but don't know exactly what the command is,then is there a way to find that command or the list of commands having editor as a substring.

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 :: Find All First Level Subdirectories Under The Current Directory?

Jan 24, 2011

1. How can you find all first level subdirectories under the current directory?
2. How will you show the last 100 lines of the file "foo.log"?
3. How will you Stream the contents of a the log file "foo.log" as it gets written to?
4. How can you grep for a pattern on a gzip'ed file? e.g., find "foo" in bar.gz
5. Find all lines in the file "foo" which DON'T have the pattern "bar"
6. Your web server is running very slowly. If you can login to the server, what command will you run to find out cpu and memory use?
7. Extract the file foo which is a part of the tar'ed, gzip'ed file bar.tar.gz
8. You attach a usb disk to your linux desktop, but it does not show up. How can you get more information about the error?
9. What is the secure way to login to remote systems?
10. What is the difference between TELNET and SSH?
11. Given a file 'a' with the following permissions -rwxrwxrwx 1 rohit rohit 0 2011-01-24 13:30 a Change its permissions such that it is only readable and writable by its owner, not accessible by anybody else in the group and only executable by the world
12. Difference between using ' and " for quoting a string / command in a shell
13. In the attached text file (test.txt) replace all occurrences of 'red' with 'yellow' without using an editor (i.e. from the command line)
14. How would you suppress output written to stderr by a command
15. Meaning of the #! notation in scripts e.g. #!/bin/sh
16. What is the output of the attached shell script test.sh Scripting questions, all based on the attached file access.log. Use one of perl, python, ruby, or shell scripts to solve these questsions. If any answer is obtained using just the command line, please include those commands as well.
17. How many accesses were made between 10am and 11.30am on Jan 24, 2011?
18. How many unique IP addresses accessed this server?
19. For every IP address which accessed this server, output a report showing number of hits for every type of HTTP status. For e.g., IP 192.168.1.20 has 164 hits with status 404 and 1690 hits with status 200.

View 8 Replies View Related

Programming :: Requesting Shell Script That Only Outputs Directories That Contain Subdirectories?

Jan 7, 2010

I have a directory that has about 5,000+ folders in it and I'd like to run a script that outputs any directory that contains a subdirectory.

View 4 Replies View Related

General :: Script To Open All Subdirectories Of A Single Directory And Then Run A Command?

Mar 24, 2010

I am trying to write a very simple script that will go to every subdirectory of a single directory and run a command (lets call it make_ndx).I know I can write this the long way with in a text document with something like:

cd /"the directory"/"the 1st subdirectory"
make_ndx
cd ..
cd "the 2nd subdirectory"
cd ..

Alternatively, I also tried: for i in 'find /path/somemorepath -type d -mindepth 1'; do cd $i; make_ndx -f *.gro; done which returns me with the error cd: find: no such file or directory. But if I run the find command by itself to test if I am calling the right directories, it gives me the exactly the output I am looking for. Any ideas? Should I just write the find results to a file and loop through the contents of the file (which seems a little bit like overkill) or am I just making a simple typographical mistake and I am just not seeing it?

View 7 Replies View Related

General :: Specific File Name Renaming In All Sub Directories?

Apr 4, 2011

I have a dir (pub_html) with 45 sub dirsand in each there is a file with name file123.html) what command can I use to rename all files with this name in all sub dirs to file456.html ? I'm on opensuse 11.3

View 14 Replies View Related

General :: Linking Init Script To Specific Rc0.d, Rc1.d Etc Directories?

Aug 20, 2010

I have written an init script which I have kept under /etc/init.d, I need to create links to the directories rc0.d, rc1.d, rc2.d, rc3.d etc.. So that I can use chkconfig command to control the starting and stopping of the script at specific runlevels.

View 4 Replies View Related

General :: Recursive Delete Specific Files From Sub-directories?

Mar 4, 2011

I would like to be able to recursively delete specific various files from a directory and sub-directories. For example:

Dir/
|_sub1/
|
|_ _rm *file1 *file2 *file3

[code]....

View 11 Replies View Related

CentOS 5 :: Command To Find And Remove Specific Letters From A File?

Nov 4, 2009

I have a file with tens of thousands of lines. I need to remove specific letters eg eggs, from every line that has the letters in it. Is there a command which can help me do that easily?

View 4 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 :: List Files In Specific Directories Older Than 1 Day Or 24 Hours

Apr 7, 2011

I am trying to write a simple back up script in python where I try to list the files that are 24 hours old in specific directories that I would choose.I read the manual of find and used

find . -mtime 1 > log.dat

to get the list of files in the log.dat however I also get the path information in that list as such

./hpc06MatlabCodes/2011/Apr/3dBoxModel
./hpc06MatlabCodes/2011/Apr/3dBoxModel/vfluidIrca10.dat
./hpc06MatlabCodes/2011/Apr/3dBoxModel/vLRecoveredSystem.mat

is there a way to exclude the directories and only get the files list.

View 2 Replies View Related

General :: Assign Read Privileges To User On Specific Directories And Files

Jan 26, 2011

I am using CentOS 5.5 and I created few users (useradd john etc.) and now I want to assign privileges to this user on some directories and files in those directories. For example I want to give read privileges to directory "/documents" and all of files under that directory.

View 13 Replies View Related

OpenSUSE Network :: Setup An Apache Server On Computer Which Will Allow Browsing Of Files In A Specific Directory And Subdirectories?

Jun 13, 2011

I'm trying to setup an Apache server on my computer which will allow browsing of files in a specific directory and subdirectories, without needing any sort of authentication.

I've got the Apache2 server up and running through yast, and everything works fine as long as I try to point it to the /www/htdocs folder. However, I want to point it at another folder, which is on another partition. This partition is formatted as NTFS, if that matters at all (here's some background on some permissions issues I had with the NTFS partitions recently).

When I change the "Directory" setting in the Yast http server configuration utility to the directory on the NTFS partition I wish to use, attempting to access the server results in the following error:

Code: Access Forbidden: You don't have permission to access the requested directory. There is either no index document or the directory is read-protected. If you think this is a server error, please contact the webmaster.

Error 403
192.168.1.100
Mon Jun 13 23:43:29 2011
Apache/2.2.17 (Linux/SUSE)

View 4 Replies View Related

General :: Find A Phrase/word Recursivly In A File Tree?

Aug 31, 2010

how do I find a phrase/word recursively in a file tree in Linux?I tried find . -name ./* | grep my_phraseand I tried grep -r "register_long_arrays" *

View 5 Replies View Related

Programming :: Printing A Specific Word Out Of A File?

Jan 6, 2011

so i have a file that has the following

file1.txt
ID1 age_11 dog_n3 parent_dog_n1
ID1 age_7 dog_n4 parent_dog_n3
ID1 dog_n5 age_4
ID1 dog_n6 age_4

[Code].....

As you can see i would like the output file to be just the dogs, not the otehr information. But because the information is mixed up how can i extract only the dogs? (i cant do and awk '{print }' because the dogs are found in colounm 2 or 3 or sometimes even 4.

View 9 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 :: Bash: Replace All Occurrences Of A Word In The Last Command

Mar 9, 2011

Almost by mistake, I figured out you could do something like:

$ cp foo.data bar1.data
$ ^bar1^bar2

And that runs the same command with bar2.data instead of bar1.data. Now, how about if I have multiple occurrences of the target word? For example:

$ cp foo.data bar.data
$ ^data^index

It only replaces the first data extension. How do I get it to replace both?

View 1 Replies View Related

General :: Search Word In Group Of Files Using Command?

Oct 10, 2009

i am using openSUSE 10.3 & like to use power of terminal to do tasks.I want to search all files containing word 'echo' in given folder.What should be command.

View 14 Replies View Related

General :: Command To Sort A Text File By The Second Word?

May 14, 2010

What is the command to sort a text file by the second word?

View 4 Replies View Related

Programming :: Delete All Files With Specific Word In Filename?

May 21, 2011

I need a command to find the all files which filename contains the text "SomeText" and to delete that files!From /home/movie/wp-content/uploads/this folder I have lots of files and folders .Also I need that for folders and subfolders who contains some text in folder name "someTextInFolderName"

View 13 Replies View Related







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