Sponsored Content
Top Forums Shell Programming and Scripting Searching File in Directory and all Subdirectory and Delete Post 302934555 by Don Cragun on Sunday 8th of February 2015 03:32:04 PM
Old 02-08-2015
Is this a homework assignment?

If not, please explain what determines whether or not a file compared to your "parametrized" file should be kept or removed:
  1. Do the file names have to be the same?
  2. Do the file permissions have to be the same?
  3. Do the file owner and group IDs have to be the same?
  4. Do the file timestamps have to be the same?
  5. Do the file inode numbers have to be the same?
  6. Do the file contents have to be the same?
  7. If a file is a symbolic link, what should be removed? (The file to which the symlink points? The symlink itself? Both?)
 

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

searching each file in a directory for text

what command can i use to search the files in a directory for a text. the output would list the files containing the text. ive tried this but it is not exactly what im looking to do: find . -name "*.xml" -exec agrep searchstring {} \; (2 Replies)
Discussion started by: jim majors
2 Replies

3. Shell Programming and Scripting

Find files including subdirectory and Delete

Hello Experts, I m newbie. Could u pls help me to write script on Sun solaris- I have backup directory "/var/opt/backup/" where files are backed up in different directory "backup1" "backup2" "backup3". I want to write a shell script which i will put in crontab and daily midnight it will... (1 Reply)
Discussion started by: thepurple
1 Replies

4. UNIX for Dummies Questions & Answers

Create Year directory, date subdirectory and archive the file

Hi, After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are 1) Check if the file exists in the current directory. 2) Check if the destination directory... (2 Replies)
Discussion started by: madhunk
2 Replies

5. Shell Programming and Scripting

Shell script for searching a record,copy to a file and then delete it

Hi, I have a requirement in hand: I have a file with millions of records say file 1.I have another file, say file 2 which has 2000 records in it. The requirement is to read file2 , and remove the read record from file 1 and move i to a seperate file, file 3. For eg: Read file 2, get the... (5 Replies)
Discussion started by: kumara2010
5 Replies

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

7. Shell Programming and Scripting

Copy file after searching in a directory

Hi, I am looking for an answer for following senario: I have a text file (base.txt) which consist list of files to be searched like: base.txt abc.txt def.txt fgh.txt Now i am going to search all the listed files in another directory after reading them one by one, once i found the... (10 Replies)
Discussion started by: apjneeraj
10 Replies

8. 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

9. Shell Programming and Scripting

Move all files not in a directory into a subdirectory named for each given file

Hi Everyone! Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file. Any ideas? Thank you! (1 Reply)
Discussion started by: DanTheMan
1 Replies

10. UNIX for Dummies Questions & Answers

Searching the file in a directory

Hi Folks, I am using the putty as I need to check the logs, My query is that I know the location of my logs ..that is cd /var /logs/abc.log so I can reach to this place and open the logs in putty, But what About if I do not the location only thing I know the name of the abc.log , and I have... (1 Reply)
Discussion started by: KAREENA18
1 Replies
symlink(2)							System Calls Manual							symlink(2)

NAME
symlink - Makes a symbolic link to a file SYNOPSIS
#include <unistd.h> int symlink ( const char *path1, const char *path2 ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: symlink(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the contents of the symbolic link to create. Names the symbolic link to be created. DESCRIPTION
The symlink() function creates a symbolic link with the name specified by the path2 parameter which refers to the file named by the path1 parameter. Like a hard link (described in the link() function), a symbolic link allows a file to have multiple names. The presence of a hard link guarantees the existence of a file, even after the original name has been removed. A symbolic link provides no such assurance; in fact, the file named by the path1 parameter need not exist when the link is created. Unlike hard links, a symbolic link can cross file system boundaries. When a component of a pathname refers to a symbolic link rather than a directory, the pathname contained in the symbolic link is resolved. If the pathname in the symbolic link starts with a / (slash), the symbolic link pathname is resolved relative to the process root direc- tory. If the pathname in the symbolic link does not start with a / (slash), the symbolic link pathname is resolved relative to the direc- tory that contains the symbolic link. If the symbolic link is the last component of the original pathname, remaining components of the original pathname are appended to the con- tents of the link and pathname resolution continues. The symbolic link pathname may or may not be traversed, depending on which function is being performed. Most functions traverse the link. The functions which refer only to the symbolic link itself, rather than to the object to which the link refers, are: An error is returned if a symbolic link is named by the path2 parameter. If the file specified is a symbolic link, the status of the link itself is returned. An error is returned if a symbolic link is named as the path parameter. This call applies only to symbolic links. A symbolic link can be removed by invoking the remove() function. If the file to be renamed is a symbolic link, the symbolic link is renamed. If the new name refers to an existing symbolic link, the symbolic link is destroyed. An error is returned if a symbolic link is named as the path parame- ter. An error is returned if the symbolic link named by the path2 parameter already exists. A symbolic link can be created that refers to another symbolic link; that is, the path1 parameter can refer to a symbolic link. A symbolic link can be removed by invoking unlink(). Search access to the symbolic link is required to traverse the pathname contained therein. Normal permission checks are made on each com- ponent of the symbolic link pathname during its resolution. A Context Dependent Symbolic Link (CDSL) is a symbolic link that has a variable in the path name. The variable is resolved differently for each member system in a cluster. If the system is not a member of a cluster, the variable is resolved as if it were member0 of a cluster. See hier(5) for more information about CDSLs and the cdslinvchk(8) refernce page for information about checking the CDSL file inventory RETURN VALUES
Upon successful completion, the symlink() function returns a value of 0 (zero). If the symlink() function fails, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the symlink() function fails, errno may be set to one of the following values: The requested operation requires writing in a directory with a mode that denies write permission, or search permission is denied on a component of path2. The directory in which the entry for the symbolic link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. The path specified by the path2 parameter already exists. Too many symbolic links are found in translating path2. The length of the path1 parameter or path2 parameter exceeds PATH_MAX, or a pathname component of path2 is longer than NAME_MAX while {_POSIX_NO_TRUNC} is in effect. The path2 parameter points to a null pathname, or a component of path2 does not exist. The directory in which the entry for the symbolic link is being placed cannot be extended because there is no space left on the file system containing the directory. The new symbolic link cannot be created because there is no space left on the file system which would contain the link. There are no free inodes on the file system on which the file is being created. The operation is not applicable for this file sys- tem type. A component of path2 is not a directory. The requested operation requires writing in a directory on a read-only file system. [Tru64 UNIX] For NFS file access, if the symlink() function fails, errno may also be set to one of the following values: Indicates either that the system file table is full, or that there are too many files currently open in the system. Indicates a stale NFS file handle. An opened file was deleted by the server or another client; a client cannot open a file because the server has unmounted or unexported the remote directory; or the directory that contains an opened file was either unmounted or unexported by the server. RELATED INFORMATION
Functions: link(2), readlink(2), unlink(2) Commands: ln(1), cdslinvchk(1) Files: hier(5) Standards: standards(5) delim off symlink(2)
All times are GMT -4. The time now is 06:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy