[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

adding extension

Posted on 2006-05-16
4
Medium Priority
?
259 Views
Last Modified: 2010-04-20
hi! i need to write a shell script which checks whether a given file exists. If the file exists add the extension ".bak" at the end of the file name.
thanks..
0
Comment
Question by:btocakci
  • 2
4 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 400 total points
ID: 16693731
Hi btocakci,

First argument to the script is name of the file to which extension is to be added
if [ -f "$1" ]
then
     mv $1 $1.bak
fi

Cheers!
Sunnycoder
0
 
LVL 8

Expert Comment

by:edkim80
ID: 16693764
#!/bin/bash

find / -name filename -exec mv '{}' '{}'.bak \;
0
 

Author Comment

by:btocakci
ID: 16693962
sunnycoder i am sorry to make you spend time by these beginner qoestions but
how can i use this script for exxample i have a file as "btocakci" ..
what should i write to terminal?
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 16693984
suppose you named the script as addextension.sh
After giving it execute permissions, you need to invoke it as

/path/to/addextension.sh  /path/to/btocakci

paths can be absolute or relative
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy. ┬áThis article also serves as your NTP server documentation.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month19 days, 21 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question