Sponsored Content
Top Forums Shell Programming and Scripting BASH - read use a path as input Post 302417763 by Corona688 on Friday 30th of April 2010 03:36:32 PM
Old 04-30-2010
Try the suggestions I made earlier, as well as an ls. So instead of running ditto thrice, you can:

Code:
ls -ld "${SRC}"
ditto "$SRC" "/Volumes/BACKUPS/$DST"

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Help-prompt for path and take this as input in find command

HI , I am trying to wite a script that will prompt me saying " what is path that you want to find ?". once i specify the path, the script should put this path in the find command mentioned below and execute the script: find <path> -ctime +200 -type f -exec ls -l {} \; for example : ... (7 Replies)
Discussion started by: bsandeep_80
7 Replies

2. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

Hi I am new to writing script and want to use a Bash Piped while-read and read from user input. if something happens on server.log then do while loop or if something happend on user input then do while loop. Pseudocode something like: tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies

3. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

4. Shell Programming and Scripting

Using read to prompt for editable user input in Bash 3

Below is a simple script to prompt for user input while suggesting an editable default value at the prompt: shortname=user1 read -e -i $shortname -p "Please enter the username you would like to add: " input USERNAME="${input:-$shortname}" Please enter the username you would like to add:... (3 Replies)
Discussion started by: woodson2
3 Replies

5. Shell Programming and Scripting

BASH - read does not wait for user input in some circumstances

Hello. I am running 2 scripts : script_1 and script_2 These scripts are run as root Script 2 contains : #!/bin/bash # # ~/bin/script_2 # E_BAD_PARAM=115 # date2stamp () { date --date "$1" +%Y-%m-%d___%H:%M:%S } # USER_NAME=$1 NB_PARAM=$# PARAM0=$0 (2 Replies)
Discussion started by: jcdole
2 Replies

6. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

7. Shell Programming and Scripting

[Bash] Read History function & Read Arrowkeys

Hi. How can I create a history function? (By "read" command or so) & How can I configure a read command so that the arrow keys are not displayed so funny? (^[[A) Thanks in advance. (4 Replies)
Discussion started by: sinnlosername
4 Replies

8. Shell Programming and Scripting

Moving files from parent path to multiple child path using bash in efficient way

Hi All, Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created. /Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt /Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Discussion started by: karthikgv417
6 Replies

9. Shell Programming and Scripting

Read input from Keyboard, do not proceed if no input

Hi, I am working on a script, which requests users to enter input. Ex: read -p "Please enter your email id:" email I don't want users skipping this entry, this has to be mandatory.I dont want to proceed without input. I can do a check if variable $email is empty and proceed if not.But, i... (7 Replies)
Discussion started by: aravindadla
7 Replies

10. Shell Programming and Scripting

Bash read input in case statement not working as expected

I'm having an issue with bash read input when using a case statement. The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here. defaultans=8hrs read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies
DITTO(1)						    BSD General Commands Manual 						  DITTO(1)

NAME
ditto -- copy directory hierarchies, create and extract archives SYNOPSIS
ditto [-v] [-V] [-X] [<options>] src ... dst_directory ditto [-v] [-V] [<options>] src_file dst_file ditto -c [-z | -j | -k] [-v] [-V] [-X] [<options>] src dst_archive ditto -x [-z | -j | -k] [-v] [-V] [<options>] src_archive ... dst_directory ditto -h | --help DESCRIPTION
In its first form, ditto copies one or more source files or directories to a destination directory. If the destination directory does not exist it will be created before the first source is copied. If the destination directory already exists then the source directories are merged with the previous contents of the destination. In its second form, ditto copies a file to the supplied dst_file pathname. The next two forms reflect ditto's ability to create and extract archives. These archives can be either CPIO format (preferred for unix con- tent) or PKZip (for Windows compatibility). src_archive (and dst_archive) can be the single character '-', causing ditto to read (write) ar- chive data from stdin (or to stdout, respectively). ditto follows symbolic links provided as arguments but does not follow any links as it traverses the source or destination hierarchies. ditto overwrites existing files, symbolic links, and devices in the destination when these are copied from a source. The resulting files, links, and devices will have the same mode, access time, modification time, owner, and group as the source items from which they are copied. Pipes, sockets, and files with names beginning with .nfs or .afpDeleted will be ignored. ditto does not modify the mode, owner, group, extended attributes, or ACLs of existing directories in the destination. Files and symbolic links cannot overwrite directories or vice- versa. ditto can be used to "thin" Universal Mach-O binaries during a copy. ditto can also copy files selectively based on the contents of a BOM ("Bill of Materials") file. ditto preserves file hard links (but not directory hard links) present in the source directories and preserves setuid and setgid modes when run as the superuser. ditto will preserve resource forks and HFS meta-data information when copying unless instructed otherwise using --norsrc . Similarly, ditto will preserve extended attributes and Access Control Lists (ACLs) unless --noextattr or --noacl is passed. DITTONORSRC can be set in the environment as an alias to --norsrc --noextattr --noacl on the command line. OPTIONS
-h Print full usage. -v Print a line of output to stderr for each source directory copied. -V Print a line of output to stderr for every file, symbolic link, and device copied. -X When copying one or more source directories, do not descend into directories that have a different device ID. -c Create an archive at the destination path. The default format is CPIO, unless -k is given. CPIO archives should be stored in files with names ending in .cpio. Compressed CPIO archives should be stored in files with names ending in .cpgz. -z Create compressed CPIO archives, using gzip(1) compression. -j Create compressed CPIO archives, using bzip2(1) compression. -x Extract the archives given as source arguments. The format is assumed to be CPIO, unless -k is given. Compressed CPIO is auto- matically handled. -k Create or extract from a PKZip archive instead of the default CPIO. PKZip archives should be stored in filenames ending in .zip. --keepParent When creating an archive, embed the parent directory name src in dst_archive. --arch arch Thin Universal binaries to the specified architecture. If multiple --arch options are specified then the resulting destination file will contain each of the specified architectures (if they are present in the source file). arch should be specified as "i386", "x86_64", etc. --bom bom Copy only files, links, devices, and directories that are present in the specified BOM. --rsrc Preserve resource forks and HFS meta-data. ditto will store this data in Carbon-compatible ._ AppleDouble files on filesystems that do not natively support resource forks. As of Mac OS X 10.4, --rsrc is default behavior. --norsrc Do not preserve resource forks and HFS meta-data. If both --norsrc and --rsrc are passed, whichever is passed last will take precedence. Both options override DITTONORSRC. Unless explicitly specified, --norsrc also implies --noextattr and --noacl to match the behavior of Mac OS X 10.4. --extattr Preserve extended attributes (requires --rsrc). As of Mac OS X 10.5, --extattr is the default. --noextattr Do not preserve extended attributes (requires --norsrc). --qtn Preserve quarantine information. As of Mac OS X 10.5, --qtn is the default. --noqtn Do not preserve quarantine information. --acl Preserve Access Control Lists (ACLs). As of Mac OS X 10.5, --acl is the default. --noacl Do not preserve ACLs. --nocache Do not perform copies using the Mac OS X Unified Buffer Cache. Files read and written will not be cached, although if the file is already present in the cache, the cached information will be used. --hfsCompression When copying files or extracting content from an archive, if the destination is an HFS+ volume that supports compression, all the content will be compressed if appropriate. This is only supported on Mac OS X 10.6 or later, and is only intended to be used in installation and backup scenarios that involve system files. Since files using HFS+ compression are not readable on versions of Mac OS X earlier than 10.6, this flag should not be used when dealing with non-system files or other user-generated content that will be used on a version of Mac OS X earlier than 10.6. --nohfsCompression Do not compress files with HFS+ compression when copying or extracting content from an archive unless the content is already compressed with HFS+ compression. This flag is only supported on Mac OS X 10.6 or later. --nohfsCompression is the default. --preserveHFSCompression When copying files to an HFS+ volume that supports compression, ditto will preserve the compression of any source files that were using HFS+ compression. This flag is only supported on Mac OS X 10.6 or later. --preserveHFSCompression is the default. --nopreserveHFSCompression Do not preserve HFS+ compression when copying files that are already compressed with HFS+ compression. This is only supported on Mac OS X 10.6 or later. --sequesterRsrc When creating a PKZip archive, preserve resource forks and HFS meta-data in the subdirectory __MACOSX. PKZip extraction will automatically find these resources. --zlibCompressionLevel num Sets the compression level to use when creating a PKZip archive. The compression level can be set from 0 to 9, where 0 repre- sents no compression, and 9 represents optimal (slowest) compression. By default, ditto will use the default compression level as defined by zlib. --password When extracting a password-encrypted ZIP archive, you must specify --password to allow ditto to prompt for a password to use to extract the contents of the file. If this option is not provided, and a password-encrypted file is encountered, ditto will emit an error message. EXAMPLES
The command: ditto src_directory dst_directory copies the contents of src_directory into dst_directory, creating dst_directory if it does not already exist. The command: ditto src_directory dir/dst_directory copies the contents of src_directory into dir/dst_directory, creating dir and dst_directory if they don't already exist. The command: ditto src-1 ... src-n dst_directory copies the contents of all of the src directories into dst_directory, creating dst_directory if it does not already exist. The command: ditto --arch ppc universal_file thin_file copies the contents of universal_file into thin_file, thinning executable code to ppc-only on the fly. The command: ditto -c --norsrc Scripts -|ssh rhost ditto -x --norsrc - ./Scripts copies Scripts, skipping any resources or meta-data, to rhost. The command: pax -f archive.cpio will list the files in the CPIO archive archive.cpio. The command: pax -zf archive.cpgz will list the files in the compressed CPIO archive archive.cpgz. The command: ditto -c -k --sequesterRsrc --keepParent src_directory archive.zip will create a PKZip archive similarly to the Finder's Compress functionality. The command: unzip -l archive.zip will list the files in the PKZip archive archive.zip. ERRORS
ditto returns 0 if everything is copied, otherwise non-zero. ditto almost never gives up, preferring to report errors along the way. Diag- nostic messages will be printed to standard error. ENVIRONMENT
DITTOABORT If the environment variable DITTOABORT is set, ditto will call abort(3) if it encounters a fatal error. DITTONORSRC If DITTONORSRC is set but --rsrc, --extattr, and --acl are not specified, ditto will not preserve those additional types of meta- data. BUGS
ditto doesn't copy directories into directories in the same way as cp(1). In particular, ditto foo bar will copy the contents of foo into bar, whereas cp -r foo bar copies foo itself into bar. Though this is not a bug, some may consider this bug-like behavior. --keepParent for non-archive copies will eventually alleviate this problem. SEE ALSO
bom(5), lsbom(8), mkbom(8), cpio(1), zip(1), gzip(1), bzip2(1), tar(1). Mac OS X December 19, 2008 Mac OS X
All times are GMT -4. The time now is 08:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy