08-21-2008
I'm trying to do something similar and have been reading posts and experimenting all day. On my team, we sometimes modify a file with vi but forget to stop and make a backup copy of the original first. You can imagine that "rollback" is almost impossible with this little "problem."
I'd like to do an automatic copy, date/time stamp automatically appended to the file name, and alias vi to call this automatic copy script as follows:
vi <file>
file is automatically copied to <file>.00814201440
make your changes
quit vi
If you worked out this problem or (anyone) came up with an answer or can, please let me know, thanks!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
For example,
/tmp/folder1
includes /tmp/folder1/a /tmp/folder1/b
/tmp/folder2
includes /tmp/c
Is there a command without removing files in /tmp/folder2 first to copy the /tmp/folder1 to /tmp/folder2?
and the result should be
/tmp/folder2 will include only /tmp/folder2/a... (2 Replies)
Discussion started by: lalelle
2 Replies
2. Shell Programming and Scripting
Hi all,
*I use Uwin and Cygwin emulator.
I´m trying to search for all text files in the current folder (C/Files) and its sub folders using
find -depth -name "*.txt"
The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies
3. Shell Programming and Scripting
hello, I need to build a shell script that receives the folder to copy by parameter and copy all files except thumb.db to another folder and rename them like, file.jpg renamed to file_bb1.jpg.
can someone help me
Thanks (4 Replies)
Discussion started by: zeker
4 Replies
4. Shell Programming and Scripting
Hello!
Please, help me to find or write this simple bash-script.
I have first folder
/tmp/work/folder1
with such files:
name1.txt
name2.txt.1
name2.txt.2
name3.txt
name4.txt
name4.txt.1
name4.txt.2
name4.txt.3
etc..
I need to copy all files from folder1
to folder... (1 Reply)
Discussion started by: optik77
1 Replies
5. UNIX for Dummies Questions & Answers
Hi ,
I have a file like this, i need to trace its path and copy the files from its path to one folder. I need to replace elib.com,melib.com to F:\.Here i need to copy to a folder called image. Please help
http://elib.com/SHC/NLNLHB/020001498.pdf ... (4 Replies)
Discussion started by: umapearl
4 Replies
6. Shell Programming and Scripting
Hi all,
cp -r /tmp/Agent/* /apps/opt/Agent/TEST
When I copy files under /tmp/Agent using this command Files are getting copied to Agent folder also but I need only in the TEST folder.
Is there any way to fix this issue??\
Thanks in advance
Ananth (4 Replies)
Discussion started by: Ananthdoss
4 Replies
7. Shell Programming and Scripting
Hi experts,
I am coming to you with this basic question on copying a folder and its content from one location to another folder using PERL script.
This is my requirement.
I have a folder AB under /users/myhome
I want to copy AB and its contents to /user/workspace.
Finally it should... (1 Reply)
Discussion started by: amvarma77
1 Replies
8. UNIX for Dummies Questions & Answers
Hi,
I have a folder which contains some files like this.
bin.000001
bin.000002
bin.000003
bin.000004
bin.000005
bin.000129
bin.index
I want to copy all these files to a new folder except the last files.
Please provide some ideas.
Please use next time code tags for your code... (6 Replies)
Discussion started by: arijitsaha
6 Replies
9. Shell Programming and Scripting
I have a script which generates env setup xml file by reading path.It read the path and checks if there is any file/dir present recurseively.
If a file is found under sub directory then it will read the file and the values from the file are passed to generate xml format.
Problem is if i have a... (0 Replies)
Discussion started by: Optimus81
0 Replies
10. Shell Programming and Scripting
Hello All
A similar question like this was asked before but I need to change part of the question.
I've two folders, Folder A contains some image files in 150 subfolders;
Folder B contains text files in 350 subfolders.
All image files in Folder A have the same filename as the text... (5 Replies)
Discussion started by: chlade
5 Replies
LEARN ABOUT DEBIAN
smart_pointer
smart_pointer(7rheolef) rheolef-6.1 smart_pointer(7rheolef)
NAME
smart_pointer, smart_pointer_clone - reference counted safe pointer with true copy semantic
DESCRIPTION
Here is a convenient way to implement a true copy semantic, by using shallow copies and reference counting, in order to minimise memory
copies. This concept is generally related to the smart pointer method for managing memory.
The true semantic copy is defined as follows: if an object A is assigned to B, such as A = B, every further modification on A or B does not
modify the other.
Notice that this class differs from the boost::shared_ptr class that implements safe pointers without the true copy semantic.
CLONE VARIANT
The smart_pointer_clone variant uses a T* T::clone() const member function instead of the usual T::T() copy constructor for obtaining a
true copy of the data. This variant is motivated as follows: when using hierarchies of derived classes (also known as polymorphic
classes), the usual copy is not possible because c++ copy constructors cannot be virtual, so you cannot make a copy this way. This is a
well-known problem with C++'s implementation of polymorphism.
We uses a solution to the non-virtual copy constructor problem which is suggested by Ellis and Stroustrup in "The Annotated LRM". The
solution is to require the T class to provide a virtual clone method for every class which makes a copy using new and the correct copy con-
structor, returning the result as a pointer to the superclass T. Each subclass of T overloads this function with its own variant which
copies its own type. Thus the copy operation is now virtual and furthermore is localised to the individual subclass.
NOCOPY VARIANT
This variant of the smart pointer is designed for use on objects that cannot (or must not) be copied. An example would be when managing an
object that contains, say, a file handle. It is essential that this not be copied because then you get the problem of deciding which copy
is responsible for closing the file. To avoid the problem, wrap the file handle in a class and then manage a unique instance of it using a
smart_pointer_nocopy. This ensures that the file handle cannot be copied and is closed when the last alias is destroyed.
The interface to the nocopy variant is the same as smart_pointer but with all operations that perform copying forbidden. In fact, because
all three variants are instances of a common superclass, the forbidden methods do exist but will cause an error and exit if they are
called.
The following modifiers cannot be used because they use copying of the pointed-to object and will thereore cause an error:
T* operator-> ();
T& operator* ();
T* pointer ();
T& data ();
EFERENCES
[1] A. Geron and F. Tawbi,
Pour mieux developper avec C++ : design pattern, STL, RTTI et smart pointers,
InterEditions, 1999. Page 118.
[2] STLplus, http://stlplus.sourceforge.net/stlplus3/docs/smart_ptr.html
for the clone and nocopy variants.
IMPLEMENTATION
template <class T, class C>
class smart_pointer_base {
public:
// allocators:
smart_pointer_base (T* p = 0);
smart_pointer_base (const smart_pointer_base<T,C>&);
smart_pointer_base<T,C>& operator= (const smart_pointer_base<T,C>&);
~smart_pointer_base ();
// accessors:
const T* pointer () const;
const T& data () const;
const T* operator-> () const;
const T& operator* () const;
// modifiers:
T* pointer ();
T& data ();
T* operator-> ();
T& operator* ();
// implementation:
private:
struct counter {
T* _p;
int _n;
counter (T* p = 0);
~counter ();
int operator++ ();
int operator-- ();
};
counter *_count;
#ifndef TO_CLEAN
public:
int reference_counter() const { return _count != 0 ? _count->_n : -1; }
#endif // TO_CLEAN
};
rheolef-6.1 rheolef-6.1 smart_pointer(7rheolef)