Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

bash scripting question

Posted on 2006-11-26
4
Medium Priority
?
224 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 2000 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

Technology Partners: 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

A short article about problems I had with the new location API and permissions in Marshmallow
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

609 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