- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Bounre shell script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2002 01:54 PM
12-15-2002 01:54 PM
Bounre shell script help
The vi editor does not create backup copies as do some editors. If you edit a file and write the file to disk, you lose the orgial file. Write a Bourne shell script called "myvi" that will create a ".bak" file if you mkade any editing changes to the file while in vi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2002 02:42 PM
12-15-2002 02:42 PM
Re: Bounre shell script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2002 02:55 PM
12-15-2002 02:55 PM
Re: Bounre shell script help
#!/usr/bin/sh
if [ "$#" = "0" ] ; then
echo " Wrong Usage:
Please enter the file name to be edited:"
exit
fi
file=$1
cp $file $file.ori
vi $file
Use this script and see how it goes.
syntax to run is:
./myvi.sh
it copies file to file.ori and makes the changes to file.
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2002 03:56 PM
12-15-2002 03:56 PM
Re: Bounre shell script help
You will need to consider using "RCS" or "SCCS" for keeping revisions of files. Just create an archive of your file using the command "ci", check out the file using "co", use it. Once you are done with the changes, check it in back into the archive so that this copy will be safe. In case if you want to go back, you can always check out the previous version from the archive file.
You can keep revisions and can get the file of any date and anytime you want.
Look at "rcs" man page for more details.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2002 07:46 PM
12-15-2002 07:46 PM
Re: Bounre shell script help
You can just use the "view" editor instead of "vi".
If you use view then the original file opened will be marked as readonly and you can make changes to the original file.
Revert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2002 04:59 PM
12-16-2002 04:59 PM
Re: Bounre shell script help
if you are using the *classical* ZZ to save your files, your could simply put a "macro" into your "$HOME/.exrc" to save the old file first:
"this goes into your $HOME/.exrc
"comments after a quote are fine
map ZZ :!cp % %.org^V^M:wq^V^M
"the ^V^M is Ctrl-V, Ctrl-M
Well, the "map" line alone would be fine. Next time you start your "vi" and try to save something with "ZZ" (in commadn mode), you should get a the original move aside as "*.old".
You'll need write permission in that directory, though...
FWIW,
Wodisch
PS: maybe "vim" would be a better solution, I think you can instruct that to make a copy automatically...