Sponsored Content
Top Forums Shell Programming and Scripting Find command, -name by directory and subdirectory? Post 302348619 by methyl on Friday 28th of August 2009 06:51:21 PM
Old 08-28-2009
PHP

Code:
#!/bin/ksh
find /one/ -type f -name file1\.txt -print | while read FILENAME
do
       # Is the directory name above the filename "three" ?
       THREE1="`dirname ${FILENAME}`"
       THREE="`basename ${THREE1}`"
        if [ "${THREE}" = "three" ]
        then
               echo "${FILENAME}"
        fi
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate file's size in directory and subdirectory

Hi, I have written one script to calculate total space of all file in one directory, ignoring subdirectory, it works fine. Now, I've been trying to calculate all files which includes files in any subdirectories. I use recursive function to do this, but it can work only if there is only one... (4 Replies)
Discussion started by: KLL
4 Replies

2. Shell Programming and Scripting

Find files in directory and its subdirectory

I am writing a script which reads a file line by line and then assigns it to a variable like this 1090373422_4028715212.jpg. I have images with file name of this format in some other directory. In my script I want to assign variable with this file name and then find this filename in some other... (11 Replies)
Discussion started by: jyotib
11 Replies

3. UNIX for Dummies Questions & Answers

how to find a file named vijay in a directory using find command

I need to find whether there is a file named vijay is there or not in folder named "opt" .I tried "ls *|grep vijay" but it showed permission problem. so i need to use find command (6 Replies)
Discussion started by: amirthraj_12
6 Replies

4. Shell Programming and Scripting

How to list directory and subdirectory?

Hi, I want to list all the directory and subdirectories under any directory. For eg. i am in a directory called A and want to check all directories under A. Output should be as below. /A /A/a1 /A/a1/a2 /A/b1 /A/c1/c2 A,a1,a2,b1,c1 and c2 all are directories.Just for Eg. Please... (7 Replies)
Discussion started by: anshu ranjan
7 Replies

5. Shell Programming and Scripting

Sum of file size in directory / subdirectory

Hi , I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level .. #!/bin/ksh FNAME='.pdf' S_PATH=/abc/def/xyz find $S_PATH -exec ls -lad... (4 Replies)
Discussion started by: Vaddadi
4 Replies

6. UNIX for Dummies Questions & Answers

How to move all files in a directory and subdirectory?

I'm trying to organize my MB Pro by moving all my jpeg files to a single folder from the desktop. There are some on the desktop that are not in any folder. I was at the command line and typed mv *.jpg "Jpeg files" but it only moved the files that were on the desktop, not any of the ones that... (3 Replies)
Discussion started by: Straitsfan
3 Replies

7. Shell Programming and Scripting

How can i find a word inside a file from a directory and it's subdirectory ?

Suppose i have a word "mail". I have to search this word in all files inside a directory and it's sub-directories. It will also search in all hidden directory and sub-directories. If it finds this word in any file it will list that file. How can i do this with perl/ruby/awk/sed/bash or... (9 Replies)
Discussion started by: cola
9 Replies

8. Shell Programming and Scripting

Remove all files except the subdirectory(without pattern) in a directory

I used rm * and it deleted the files in the directory but gives and error message for unsuccessful subdirectory deletion. "rm: cannot remove 'DirectoryName': Is a directory" I dont want to explicitly get the above error. What are the modifications I have to do in the rm command? (3 Replies)
Discussion started by: duplicate
3 Replies

9. UNIX for Advanced & Expert Users

Make a subdirectory the root directory

I have a series of configuration files to deliver to multiple unix environments (dev, test, bench, prod etc). However I don't to modify them for each environment. The files are text which currently contain this type of directory information IN=/DVT/ms/sas/reception/PIL_QPA_SID/GSPIN001... (5 Replies)
Discussion started by: clarcombe
5 Replies

10. Shell Programming and Scripting

Searching File in Directory and all Subdirectory and Delete

Hi All, My directory structure is like Directory1 SubDirectory1 SubDirectory2 SubDirectory3 I have main directories and subdirectories underneath. I want to write a shell script where I will be passing file name as a parameter, Now I want to find all the files in Directory1... (19 Replies)
Discussion started by: John William
19 Replies
INFO(1) 							   User Commands							   INFO(1)

NAME
info - read Info documents SYNOPSIS
info [OPTION]... [MENU-ITEM...] DESCRIPTION
Read documentation in Info format. OPTIONS
-k, --apropos=STRING look up STRING in all indices of all manuals. -d, --directory=DIR add DIR to INFOPATH. --dribble=FILENAME remember user keystrokes in FILENAME. -f, --file=FILENAME specify Info file to visit. -h, --help display this help and exit. --index-search=STRING go to node pointed by index entry STRING. -n, --node=NODENAME specify nodes in first visited Info file. -o, --output=FILENAME output selected nodes to FILENAME. -R, --raw-escapes output "raw" ANSI escapes (default). --no-raw-escapes output escapes as literal text. --restore=FILENAME read initial keystrokes from FILENAME. -O, --show-options, --usage go to command-line options node. --subnodes recursively output menu items. --vi-keys use vi-like and less-like key bindings. --version display version information and exit. -w, --where, --location print physical location of Info file. The first non-option argument, if present, is the menu entry to start from; it is searched for in all `dir' files along INFOPATH. If it is not present, info merges all `dir' files and shows the result. Any remaining arguments are treated as the names of menu items relative to the initial node visited. For a summary of key bindings, type h within Info. EXAMPLES
info show top-level dir menu info info show the general manual for Info readers info info-stnd show the manual specific to this Info program info emacs start at emacs node from top-level dir info emacs buffers start at buffers node within emacs manual info --show-options emacs start at node with emacs' command line options info --subnodes -o out.txt emacs dump entire manual to out.txt info -f ./foo.info show file ./foo.info, not searching dir REPORTING BUGS
Email bug reports to bug-texinfo@gnu.org, general questions and discussion to help-texinfo@gnu.org. Texinfo home page: http://www.gnu.org/software/texinfo/ COPYRIGHT
Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. info 4.13 July 2010 INFO(1)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy