Sponsored Content
Top Forums Shell Programming and Scripting Help on Backing up all the files in the subdirectories under a parent directory Post 302727609 by raj.sreenu on Tuesday 6th of November 2012 01:31:48 PM
Old 11-06-2012
Help on Backing up all the files in the subdirectories under a parent directory

Hi,

I am not too familiar with Unix scripting but I have to write code to find all the files under all the sub directories under a parent directory of unix location and move them to the corresponding Windows location.

For eg: I have \home\sreenu\Files\
Under neath this I have multiple sub directories such as:
Quote:
\home\sreenu\Files\MyFiles\archive
\home\sreenu\Files\MyFiles1\One\archive
\home\sreenu\Files\MyFiles2\archive
etc..
.

and I have the corresponding windows structure where I have the mount point created to access these locations from unix:

Quote:
\win001\bkp\Files\MyFiles\archive
\win001\bkp\Files\\MyFiles1\One\archive
\win001\bkp\Files\MyFiles2\archive
Please look into the code below:

Code:
export ALL_FILE_PATH="\home\sreenu\Files\";
export BKP_FILE_PATH="\win001\bkp\Files\";
export BKP_FILE_NAME="Backup_List.txt";

 find $ALL_FILE_PATH/ -mindepth 1 -type d | grep archive$ >> $ALL_FILE_PATH/$BKP_FILE_NAME;

cat $ALL_FILE_PATH/$BKP_FILE_NAME | while read line
do
cd $line;
if [ $(find . -maxdepth 1 -type f | wc -l) == "0" ]
then 
echo "no files";
else 
echo $line | sed -e "s/\$ALL_FILE_PATH/\$BKP_FILE_PATH/g"

Could you please help me as this is very urgent for me.

Awaiting your reply.

Regards,
Raj
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search files in a directory and its subdirectories

Hello my friends, I need to write a simple shell bad file :D that search and delete a file it's name 'Microsoft.txt' in the current directory and its subdirectories? So can you help to guide me how i can write this shell, Just give me the beginning :o thank you. (1 Reply)
Discussion started by: Net-Man
1 Replies

2. UNIX for Dummies Questions & Answers

How to remove directory with subdirectories and files?

I'm trying to remove several directories which contains sun-dirs and files inside. I used the command rm -r <dirname> But, it always ask "examine file in directory <dirname> yes/no?" line by line. So, i need to write "y" for every line. How can i skip this step and remove all directories with... (9 Replies)
Discussion started by: ppa108
9 Replies

3. UNIX for Dummies Questions & Answers

Find Files in a Directory Excluding Subdirectories

Hi, I have a filename Location.txt in a directory /abc. Similar name file is present in its subdirectory /abc/xyz. I want to find the file which is present only in /abc and not in /abc/xyz. Please any1 of u can provide a quick suggestion. Its very urgent. Thanks, Amol (2 Replies)
Discussion started by: Amol_Dicholkar
2 Replies

4. Shell Programming and Scripting

Replace a string in all files under a directory and its subdirectories

Hello Friends, I've been trying to write a script which finds a string and change it with another string. For this i want to search all files (with its arguments) under a spesific directory and its subdirectories. For example lets assume i want to replace an IP= 192.168.0.4 with another... (4 Replies)
Discussion started by: EAGL€
4 Replies

5. UNIX for Dummies Questions & Answers

Listing files in a non-parent directory

Hi, Edit: The title should really read listing files in a non-parent directory, sorry! Im trying to get one of my Bash scripting assignments done for uni and now I'm stuck. This is probably going to be one of those kick yourself moments but, in my script I have a variable usrDir which... (2 Replies)
Discussion started by: Adzi
2 Replies

6. Shell Programming and Scripting

Bash: Gzip files in Directory and itīs Subdirectories

Hello dear Community, I have a task to wrtie a script which will gzip not zipped files in a directory and itīs subdirectories. I succeeded in gzippung the directory but not the subdirectories: #/bin/bash #go to the directory where to zip cd $1 #Zip unzipped files for i in `ls | xargs... (2 Replies)
Discussion started by: JamesCarter
2 Replies

7. Shell Programming and Scripting

Find files only in current directory...not subdirectories

Hi, I have to find files only in the current directory...not in the sub directories. But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help..I tried to use maxdepth..but it is not working in AIX. (2 Replies)
Discussion started by: vsachan
2 Replies

8. Shell Programming and Scripting

How to list all Subdirectories and files with its full path in a parent directory?

How to list all Subdirectories and files with its full path in a parent directory? (1 Reply)
Discussion started by: johnveslin
1 Replies

9. Shell Programming and Scripting

Find/searching files in subdirectories excluding the fiels in Parent Directory

Hi All, requirement is to find and remove the files from sub directories but it should exclude the files from parent directory. At present i am using the below one but it finds and remove files from both parent and sub directories. find ${PATH} -type f \( -name securitas\* -o -name \*gz... (1 Reply)
Discussion started by: Naveenkk
1 Replies

10. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies
nfsd(7) 						 Miscellaneous Information Manual						   nfsd(7)

NAME
nfsd - special filesystem for controlling Linux NFS server SYNPOSIS
mount -t nfsd nfsd /proc/fs/nfsd DESCRIPTION
The nfsd filesystem is a special filesystem which provides access to the Linux NFS server. The filesystem consists of a single directory which contains a number of files. These files are actually gateways into the NFS server. Writing to them can affect the server. Reading from them can provide information about the server. This file system is only available in Linux 2.6 and later series kernels (and in the later parts of the 2.5 development series leading up to 2.6). This man page does not apply to 2.4 and earlier. As well as this filesystem, there are a collection of files in the procfs filesystem (normally mounted at /proc) which are used to control the NFS server. This manual page describes all of these files. The exportfs and mountd programs (part of the nfs-utils package) expect to find this filesystem mounted at /proc/fs/nfsd or /proc/fs/nfs. If it is not mounted, they will fall-back on 2.4 style functionality. This involves accessing the NFS server via a systemcall. This sys- temcall is scheduled to be removed after the 2.6 kernel series. DETAILS
The three files in the nfsd filesystem are: exports This file contains a list of filesystems that are currently exported and clients that each filesystem is exported to, together with a list of export options for that client/filesystem pair. This is similar to the /proc/fs/nfs/exports file in 2.4. One difference is that a client doesn't necessarily correspond to just one host. It can respond to a large collection of hosts that are being treated identically. Each line of the file contains a path name, a client name, and a number of options in parentheses. Any space, tab, newline or back- slash character in the path name or client name will be replaced by a backslash followed by the octal ASCII code for that character. threads This file represents the number of nfsd thread currently running. Reading it will show the number of threads. Writing an ASCII decimal number will cause the number of threads to be changed (increased or decreased as necessary) to achieve that number. filehandle This is a somewhat unusual file in that what is read from it depends on what was just written to it. It provides a transactional interface where a program can open the file, write a request, and read a response. If two separate programs open, write, and read at the same time, their requests will not be mixed up. The request written to filehandle should be a client name, a path name, and a number of bytes. This should be followed by a new- line, with white-space separating the fields, and octal quoting of special characters. On writing this, the program will be able to read back a filehandle for that path as exported to the given client. The filehandle's length will be at most the number of bytes given. The filehandle will be represented in hex with a leading 'x'. The directory /proc/net/rpc in the procfs filesystem contains a number of files and directories. The files contain statistics that can be display using the nfsstat program. The directories contain information about various caches that the NFS server maintains to keep track of access permissions that different clients have for different filesystems. The caches are: auth.domain This cache maps the name of a client (or domain) to an internal data structure. The only access that is possible is to flush the cache. auth.unix.ip This cache contains a mapping from IP address to the name of the authentication domain that the ipaddress should be treated as part of. nfsd.export This cache contains a mapping from directory and domain to export options. nfsd.fh This cache contains a mapping from domain and a filesystem identifier to a directory. The filesystem identifier is stored in the filehandles and consists of a number indicating the type of identifier and a number of hex bytes indicating the content of the iden- tifier. Each directory representing a cache can hold from 1 to 3 files. They are: flush When a number of seconds since epoch (1 Jan 1970) is written to this file, all entries in the cache that were last updated before that file become invalidated and will be flushed out. Writing 1 will flush everything. This is the only file that will always be present. content This file, if present, contains a textual representation of ever entry in the cache, one per line. If an entry is still in the cache (because it is actively being used) but has expired or is otherwise invalid, it will be presented as a comment (with a leading hash character). channel This file, if present, acts a channel for request from the kernel-based nfs server to be passed to a user-space program for han- dling. When the kernel needs some information which isn't in the cache, it makes a line appear in the channel file giving the key for the information. A user-space program should read this, find the answer, and write a line containing the key, an expiry time, and the content. For example the kernel might make nfsd 127.0.0.1 appear in the auth.unix.ip/content file. The user-space program might then write nfsd 127.0.0.1 1057206953 localhost to indicate that 127.0.0.1 should map to localhost, at least for now. If the program uses select(2) or poll(2) to discover if it can read from the channel then it will never see and end-of-file but when all requests have been answered, it will block until another request appears. In the /proc filesystem there are 4 files that can be used to enabled extra tracing of nfsd and related code. They are: /proc/sys/sunrpc/nfs_debug /proc/sys/sunrpc/nfsd_debug /proc/sys/sunrpc/nlm_debug /proc/sys/sunrpc/rpc_debug They control tracing for the NFS client, the NFS server, the Network Lock Manager (lockd) and the underlying RPC layer respectively. Deci- mal numbers can be read from or written to these files. Each number represents a bit-pattern where bits that are set cause certain classes of tracing to be enabled. Consult the kernel header files to find out what number correspond to what tracing. SEE ALSO
nfsd(8), rpc.nfsd(8), exports(5), nfsstat(8), mountd(8) exportfs(8). AUTHOR
NeilBrown 3 July 2003 nfsd(7)
All times are GMT -4. The time now is 05:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy