Sponsored Content
Top Forums Shell Programming and Scripting Problem with mv command and touch command Post 302508873 by Antcam on Tuesday 29th of March 2011 10:22:45 AM
Old 03-29-2011
Thanks for your reply;
I cannot decide if to make a copy of the file or not, this particular file contains particular data of the current day, so it has to be archived in another directory before re-creating it.

a) I want (in this case) this file generated in $DEFAULT_PATH/$2, but this script is used by other jobs: in other cases (other jobs) the script takes the file (another file) and archives it (archiving: i mean appending the current time and date) in the same folder where the file is located (so sometimes it acts only as a "rename".

b) I know that file has just been moved to another location, but also this script (touch) is used in other situations: in other situations you must now if a particular file exists or not, because the presence/absence of the file influences the behavior to assume (so you must have scripts that can be usable in different situations)

c) I want this file moved in $DEFAULT_PATH/$2 (but as i previously said, in other situations the archive can occur in the same folder,I mean the origin folder, because the same script is used)

d) the touch script tries to re-create the file with its original name (I mean without timestamp) in the origin folder, for example:

origin folder: /usr/origin_folder/
file to archive : fileA (so you have /usr/origin_folder/fileA)
archive destination /usr/destination_folder/

-> at the end you must have /usr/destination_folder/fileA<date_time> (ex: fileA20110329161000 (2011 03 29 16.10.00)

e) after you have to re-create /usr/origin_folder/fileA, because this file should be processed by other programs, and archived at the end of the day. The day after, the programs that insert data into the file must find this file in the specific folder (so after archiving it you have to re-create it), and so on..

The needs of code are, as you said:

a) rename $1 in $1<date> (or $1.date it's the same) in the origin folder.
b) archive (mv) $1<date> in $DEFAULT_PATH/$2 (in this case; in other cases the script must archive the file in the same directory where the file is located, so i put a confrontantion of origin folder and destination folder, and if they are the same, only a rename (step a) occurs.
c) In this case i have to re-create the file that has just been archived ( I cannot put the touch command inside the movedate script because the script is used in other situations where the file to archive is not created but is uploaded or send by other systems). But for this, i think i can use a simple touch command.

So the needs are a) and b)

Thank you!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Usage of Touch Command

HI all, I am wrkin on HP Unix .. can any1 let me know da usage of Touch command in shell scripting (1 Reply)
Discussion started by: ravi.sadani19
1 Replies

2. UNIX for Dummies Questions & Answers

touch command

hello everyone i am new to this forum and was wondering if you all could help me out.... i am looking for a touch command that can touch directories as well as files that does not involve sygwin... any and all help would be appreiciated :D (3 Replies)
Discussion started by: OrthoProof USA
3 Replies

3. UNIX for Dummies Questions & Answers

reverse of touch command

If touch command sets the modification and access times of files to the current time of day, is there a command that could do the reverse of this? Say change the access times of files to an earlier time or date? Say I have this file: HOME> ls -l -rw-rw-r-- 1 orbix orbix 886 May... (1 Reply)
Discussion started by: Orbix
1 Replies

4. UNIX for Dummies Questions & Answers

touch command help

Hi, This might be the stupidest question ever but here it goes, i need to create a file with the name Hello! It's $s It using the touch command but whenever i use touch 'Hello! It's $s' i get s is undefined touch Hello! It's $s i get ' unmatched Please help ^_^ (6 Replies)
Discussion started by: wsn
6 Replies

5. UNIX for Dummies Questions & Answers

how to get the timestamp using touch command

Can any one provide answer for the below 3 requirements, 1. file.txt grep "name" file.txt > file1.txt rm -f file.txt mv file1.txt file.txt as per abov, a pattern grepped in file.txt and the content moved to again file.txt My need is i want the timestamp of file.txt before chaning and... (3 Replies)
Discussion started by: prsam
3 Replies

6. UNIX for Dummies Questions & Answers

touch command

Is there a way to do... touch ./config/newdir/newfile if neither newdir and newfile exists? man touch tells me there's not (?) Is out there another tool to do that? Thx in advance! :b: (6 Replies)
Discussion started by: funyotros
6 Replies

7. Shell Programming and Scripting

Issue with touch command

Hi, I have a touch command in my script which creates / updates a file TODAY. Then i try to find the list of files which are newer than this TODAY file. touch `date '+%m%d'`0000 TODAY cd /auto/users-35/p494856/learning/filetransfer/ find . -name "*csv" -newer... (3 Replies)
Discussion started by: arunkumarmc
3 Replies

8. Shell Programming and Scripting

Help on touch command

Hi all I changed some of my files in my hoem directory to old dates using the touch command like this touch -t 200805101024 file name but after using this command the date changed properly but it displays like below -rwxr--r-- 1 fincntrg fingrp 193619 May 10 2008 vi.pdf I... (3 Replies)
Discussion started by: thelakbe
3 Replies

9. UNIX for Dummies Questions & Answers

Using touch command in ftp

hi , I am transferring files from one unix server to another, after transfer of a file i want to touch the same file name in another directory in the destination server. How can i touch a file when i am in ftp prompt on the source server. Thanks in advance (2 Replies)
Discussion started by: nick1982
2 Replies

10. UNIX for Advanced & Expert Users

Help with Touch Command

Hello, I am trying to use touch command to create 1200 .txt files. I am using this, but it is not working. touch `seq 1 1200`.txt Regards, Siddhesh.K (5 Replies)
Discussion started by: Siddheshk
5 Replies
rename(1T)						       Tcl Built-In Commands							rename(1T)

__________________________________________________________________________________________________________________________________________________

NAME
rename - Rename or delete a command SYNOPSIS
rename oldName newName _________________________________________________________________ DESCRIPTION
Rename the command that used to be called oldName so that it is now called newName. If newName is an empty string then oldName is deleted. oldName and newName may include namespace qualifiers (names of containing namespaces). If a command is renamed into a different namespace, future invocations of it will execute in the new namespace. The rename command returns an empty string as result. EXAMPLE
The rename command can be used to wrap the standard Tcl commands with your own monitoring machinery. For example, you might wish to count how often the source command is called: rename ::source ::theRealSource set sourceCount 0 proc ::source args { global sourceCount puts "called source for the [incr sourceCount]'th time" uplevel 1 ::theRealSource $args } SEE ALSO
namespace(1T), proc(1T) KEYWORDS
command, delete, namespace, rename ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl rename(1T)
All times are GMT -4. The time now is 07:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy