copy specific files and count them - not as easy as it seems!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting copy specific files and count them - not as easy as it seems!
# 8  
Old 04-20-2011
This is very central to the whole unix thing -- many false rumors float around this. A script is a pretty fully qualified executable in UNIX, compared to other languages. You are allowed one argument on the first line, BTW, for things like sed and awk that need -f or such to tolerate commands from a file.
# 9  
Old 04-20-2011
@ DGPickett, could you explain what this construct does,
Quote:
Originally Posted by DGPickett
I like "script_chain | read var_name" over "var+name=$( script chain )" over "var_name=`script_chain`", it just flows left to right, no unnecessary nesting.
Relative to the code posted. I just don't get it.

TIA.
# 10  
Old 04-25-2011
There are three ways to get stdout strings into a variable, and the back-quotes is the oldest, but I like it least, as there is no symmetry check in vi, or nesting. So, unless I am writing for bourne sh, I never say '`'.

The $(command) introduced with ksh allows vi % symmetry checking and allows nesting. (Be careful to use balanced paren pairs (...) in 'case $var in' cases!)

However, the simplest thing for simple values, not multi-line and not preserving whitespace, is just '| read var'. It introduces no nesting.

For lists in to lists on command line: '| xargs -n999 command '

For lists to get individual processing: '| while read var ; do ... ; done'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy Specific Files Recursively

Is it possible to only copy selected files+its directories when you are copying recursively? find /OriginalFolder/* -type -d \{ -mtime 1 -o -mtime 2 \ } -exec cp -R {} /CopyTo/'hostname'__CopyTo/ \; -print From the above line, I want to only copy *txt and *ini files from /OriginalFolder/* ... (4 Replies)
Discussion started by: apacheLinux
4 Replies

2. Shell Programming and Scripting

Copy files based on specific word in a file name & its extension and putting it in required location

Hello All, Since i'm relatively new in shell script need your guidance. I'm copying files manually based on a specific word in a file name and its extension and then moving it into some destination folder. so if filename contains hyr word and it has .md and .db extension; it will move to TUM/HYR... (13 Replies)
Discussion started by: prajaktaraut
13 Replies

3. Shell Programming and Scripting

Rsync to copy specific subfolders and files to new directory

RootFolderI: RootFolderI/FolderA/Subfolder1/Subsub1/JPG1.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub1/JPG2.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub2/JPG3.jpg . . . RootFolderI/FolderB/Subfolder1/Subsub1/JPG4.jpg -> want this jpg ... (1 Reply)
Discussion started by: blocnt
1 Replies

4. Post Here to Contact Site Administrators and Moderators

How to count successfully copy files source to target location with check directory in Linux?

Hi guys...please any one help me .... how to copy files from source to target location if 5 files copied successfully out of 10 files then implement success=10 and if remaining 5 files not copied successfully then count error=5 how to implement this condition with in loop i need code linux... (0 Replies)
Discussion started by: sravanreddy
0 Replies

5. Shell Programming and Scripting

How to copy a directory without specific files?

Hi I need to copy a huge directory with thousands of files onto another directory but without *.WMV files (and without *.wmv - perhaps we need to use *.). Pls advise how can I do that. Thanks (17 Replies)
Discussion started by: reddyr
17 Replies

6. Shell Programming and Scripting

How to copy specific files when you don't know the file name?

I hope this isn't as silly as it sounds from the title of the thread. I have software that outputs files where the name starts with a real number followed by underscore as a prefix to an input file name. These will list in the directory with the file with the smallest real number prefix as the... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

7. Shell Programming and Scripting

Need script to count specific word and iterate over number of files.

Hi Experts, I want to know the count of specific word in a file. I have almost 600+ files. So I want to loop thru each file and get the count of the specific word. Please help me on achieving this... Many thanks (2 Replies)
Discussion started by: elamurugu
2 Replies

8. UNIX for Dummies Questions & Answers

Unix command to count the number of files with specific characters in name

Hey all, I'm looking for a command that will search a directory (and all subdirectories) and give me a file count for the number of files that contain specific characters within its filename. e.g. I want to find the number of files that contain "-a.jpg" in their name. All the searching I've... (6 Replies)
Discussion started by: murphysm
6 Replies

9. Shell Programming and Scripting

Recursively copy only specific files from a directory tree

Hi I am a shell-script newbie and am looking to synchronize certain files in two directory structures. Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over. I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)
Discussion started by: sharpsharkrocks
3 Replies

10. Solaris

To copy the files newer than specific date

Dear all, Can you help me in copying files newer than speciifc date Thanks in advance, Rajesh (3 Replies)
Discussion started by: RAJESHKANNA
3 Replies
Login or Register to Ask a Question