We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,610 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

a question on a bash script

I am trying to understand one test script, which includes

if [ ! -f mahout-work/reuters21578.tar.gz ]; then
echo "Downloading Reuters-21578"
curl http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz \
                     -o mahout-work/reuters21578.tar.gz
fi

What does the condition of

! -f mahout-work/reuters21578.tar.gz

mean? And what does

curl http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.tar.gz \ -o mahout-work/reuters21578.tar.gz

stand for? Thanks.

3
Contributors
2
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
4
Views
Question
Answered
winecoding
Junior Poster in Training
56 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Basically in the first part of the code the condition in the if statement says "if the file reuters21578 does not exist in the mahout-work directory"
Note: The ! is the logical NOT operator.


If the file does not exist in the specified directory the code under the if statement (the 2nd part you wanted understand) uses the program curl to download the file from a website and saves it in the mahout-work directory.

JasonHippy
Practically a Posting Shark
862 posts since Jan 2009
Reputation Points: 615
Solved Threads: 146
Skill Endorsements: 5

What does the condition of
(Toggle Plain Text)
! -f mahout-work/reuters21578.tar.gz
mean? And what does

it means that if the mahout-work/reuters21578.tar.gz is not a file (i.e does not exist ) then do what's after the if statement ,else do nothing

alaa sam
Junior Poster
167 posts since Nov 2010
Reputation Points: 8
Solved Threads: 11
Skill Endorsements: 0
Question Answered as of 1 Year Ago by JasonHippy and alaa sam

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0726 seconds using 2.66MB