Sponsored Content
Top Forums Shell Programming and Scripting SCP and then touch .done file Post 302410728 by jim mcnamara on Tuesday 6th of April 2010 05:02:36 PM
Old 04-06-2010
I think this is what you want:
Code:
# make an archive directory if it is not there

[[ ! -d /directory ]]  && mkdir /directory/completed
cd /directory

for file in *
 do
           [[ -d $file ]] && continue  # skip subdirectories
           scp $file user@host:/
           mv $file /directory/completed/$file_$(date "+%Y%m")
           ssh user@host "touch /$file.done"
 done

If you plan to run this script more than once on a given directory then:
You need to move the files out of /directory and off someplace where the
"for file in *" will not find them.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

command 'touch -c file/dir'

Dear expert, what is this command touch -c filename using for? I find if execute and filename is existed, it update the date to now. If the filename is not exeisted, it don't create the file.. so what is this command using for? Thank a lot! (1 Reply)
Discussion started by: zp523444
1 Replies

2. Shell Programming and Scripting

How to empty file contents w/o rm and touch

Hi all, Can any one tell me how to empty the contents of a file in unix without using the following sequence : rm <file> ; touch <file> is there any command in unix?? is it possible through shell scripting? If so, how? -krishna (7 Replies)
Discussion started by: kris_kris
7 Replies

3. Shell Programming and Scripting

How to touch a file 30min ago

I know how to touch like this touch -t 199908031046 /tmp/file1 But I want to create a cron job for touch a file which 30 min ago in Solaris which haven't -mmin Can I use like this ? touch -t `date +%s` - 30 /tmp/file1 Because I want to file the file which older than 30min. Thanks, (6 Replies)
Discussion started by: kennylcn
6 Replies

4. UNIX for Dummies Questions & Answers

Touch all files and subdirectories (recursive touch)

I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks! I tried something i found online, find . -print0 | xargs -r0 touch but I got the error: xargs: illegal option -- r (5 Replies)
Discussion started by: glev2005
5 Replies

5. Shell Programming and Scripting

Touch New File with First Line

I am interested in creating a new file from a KSH script where the first line is printed. I know how to create the file, but creating with a pre-defined first line is what I need help with. My code below creates the file, but how do I accomplish that and do it so that when I open that txt file... (5 Replies)
Discussion started by: royarellano
5 Replies

6. Shell Programming and Scripting

Aging file not use and touch

Hi all, Need advice from expect, below is my scripts to find the file not use and touch in storage and other directory. This scripts divide by: 1. 30 days 2. 90 days 3. 180 days 4. 1 years 5. 3 years 6. 5 years Then count total size in GB from 6 each category. Sample my... (5 Replies)
Discussion started by: sheikh76
5 Replies

7. UNIX for Dummies Questions & Answers

Protect a file against touch

Afternoon, the stat command is used against a file to ascertain date created and last modification time. However a different individual if they so chose could use the touch command to alter the date created or modification time. Is there anyway to protect against this ? thanks Steve (2 Replies)
Discussion started by: sevans29
2 Replies

8. Shell Programming and Scripting

Create a trigger file using touch

Hi, I need to create a trigger file named "start" at 4 pm daily . Once this file is created , another process would be initiated. How do i do it using touch command in unix ? My script that should have touch command shall be present in a dir /app/user/script while the trigger file should be... (2 Replies)
Discussion started by: samrat dutta
2 Replies

9. UNIX for Dummies Questions & Answers

Using touch to create a file

I have noticed that the following command works touch subtext_geopdf_to_.x However this one does not touch subtext_/geopdf/_to_/.x How can I create such a file without making it think I supplied a path? (2 Replies)
Discussion started by: kristinu
2 Replies

10. Red Hat

Shell Script to touch a file

our requirement is that we need to create a touch file on 2 4 and 7 th working day of the each month ... If the days falls on saturday/sunday, the touch file should be created on next working day. We are currently on Red hat 6.5 (1 Reply)
Discussion started by: tradingspecial
1 Replies
mktrashcan(1)						      General Commands Manual						     mktrashcan(1)

NAME
mktrashcan, rmtrashcan, shtrashcan - Attaches, detaches, or shows a trashcan directory SYNOPSIS
/usr/sbin/mktrashcan trashcan directory... /usr/sbin/rmtrashcan directory... /usr/sbin/shtrashcan directory... OPERANDS
Specifies the directory that contains files that were deleted from attached directories. Whenever you delete a file in the specified directory, the file system automatically moves the file to the trashcan directory. Specifies the directory that you attach to a trashcan directory. DESCRIPTION
The trashcan utilities (mktrashcan and rmtrashcan) enable you to attach or detach an existing directory, which you specify as a trashcan directory, to any number of directories within the same fileset. A trashcan directory stores the files that are deleted with the unlink system call. For instance, you can use the mktrashcan utility to attach a trashcan directory called /usr/trashcan to one or more directories; thereafter, when you delete a file from one of the attached directories, the file system moves the file to the /usr/trashcan directory. Note that when more than one directory shares attachment to a trashcan directory, files with the same file name can overwrite each other in the trashcan directory. If you mistakenly delete a file, use the mv command to return the file from the /usr/trashcan directory to its original directory. When you enter shtrashcan at the system prompt, the system shows the trashcan directory, if one exists, for the directory you specified. It is important that trashcan directories have correct access permissions. If the permissions are too restrictive, then it may be impossi- ble to remove files from the directories that are attached to the trashcan directory. In general, all users and groups that expect to use the trashcan directory need write permission to the directory. If unexpected "permission denied" errors occur when deleting files that are in a directory attached to a trashcan directory, use the chmod command to change the permissions on the trashcan directory. RESTRICTIONS
The directory and trashcan directories must be in the same fileset; however, you can attach the trashcan directory to any directory within the fileset. EXAMPLES
The following example creates and attaches a trashcan directory, /usr/trashcan, to two directories, /usr/ray and /usr/projects/sql/test, which are in the same fileset. The chmod command adds write permission for all users and groups on the new trashcan directory. % mkdir /usr/trashcan % chmod a+w /usr/trashcan % mktrashcan /usr/trashcan /usr/ray /usr/projects/sql/test To attach the trashcan directory, /usr/trashcan, to all subdirectories in the /usr directory, enter: % mktrashcan /usr/trashcan /usr/* New subdirectories that you add beneath the /usr directory are not attached to the trashcan directory until you attach them. Also, the mktrashcan utility distinguishes between directories and files, attaching only directories to the trashcan directory. Note that an attached directory produces an EDUPLICATE_DIRS (-1165) error when /usr/trashcan is itself in the directory path you attach to (as in the previous example). You can ignore this error message. SEE ALSO
advfs(4), mkfset(8), showfsets(8) mktrashcan(1)
All times are GMT -4. The time now is 12:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy