Solved

bash scripting question

Posted on 2006-11-26
4
209 Views
Last Modified: 2010-04-16
i have a script that copies an archive from another folder on the server cp /pub/file.tgz .
how do i make so that if the file, is already there but unpacked, the script would check if the file exists
and automatically notify the person running the command, and ask for a new folder creation, and then the process to move to the new folder created
0
Comment
Question by:rares_dumitrescu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 18015333
if [ -e $file ] ; then
  echo file exists
  read -p 'new folder:' folder
fi
 
0
 
LVL 8

Expert Comment

by:John Kawakami
ID: 18017238
Do you know the contents of the file before you unpack it?
0
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 18019307
if fear you must build a list of the files in the tar check if all are there and then ask:
folder="/home/myfolder"
list=`tar tfz $folder/file.tgz`
for i in $list; do
if [ -e $file ] ; then
  echo file exists
  read -p 'new folder:' folder
break;
fi
done
cd $folder
cp /pub/file.tgz .
 tar xfz file.tgz
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Definitions and default visual studio colors 5 74
VbScript to countdown to New Year's Day 6 78
SQL Insert parts by customer 12 53
What does != "" mean in programming 8 136
This is about my first experience with programming Arduino.
In this post we will learn different types of Android Layout and some basics of an Android App.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

726 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