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
RMF(1)                                                               [nmh-1.5]                                                              RMF(1)

NAME
rmf - remove an nmh folder SYNOPSIS
rmf [+folder] [-interactive | -nointeractive] [-version] [-help] DESCRIPTION
Rmf removes all of the messages (files) within the specified (or default) folder, and then removes the folder (directory) itself. If there are any files within the folder which are not a part of nmh, they will not be removed, and an error will be produced. If the folder is given explicitly or the -nointeractive option is given, then the folder will be removed without confirmation. Otherwise, the user will be asked for confirmation. If rmf can't find the current folder, for some reason, the folder to be removed defaults to `+inbox' (unless overridden by user's profile entry "Inbox") with confirmation. If the folder being removed is a subfolder, the parent folder will become the new current folder, and rmf will produce a message telling the user this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. If rmf s used on a read-only folder, it will delete all the (private) sequences (i.e., "atr-seq-folder" entries) for this folder from your context without affecting the folder itself. Rmf irreversibly deletes messages that don't have other links, so use it with caution. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder Inbox: To find the default inbox SEE ALSO
rmm(1) DEFAULTS
`+folder' defaults to the current folder, usually with confirmation `-interactive' if +folder' not given, `-nointeractive' otherwise CONTEXT
Rmf will set the current folder to the parent folder if a subfolder is removed; or if the current folder is removed, it will make "inbox" current. Otherwise, it doesn't change the current folder or message. BUGS
Although intuitively one would suspect that rmf works recursively, it does not. Hence if you have a sub-folder within a folder, in order to rmf the parent, you must first rmf each of the children. MH.6.8 11 June 2012 RMF(1)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy