Reader small image

You're reading from  Hands-On Data Science with the Command Line

Product typeBook
Published inJan 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789132984
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Authors (3):
Jason Morris
Jason Morris
author image
Jason Morris

Jason Morris is a systems and research engineer with over 19 years of experience in system architecture, research engineering, and large data analysis. His primary focus is machine learning with TensorFlow, CUDA, and Apache Spark. Jason is also a speaker and a consultant for designing large-scale architectures, implementing best security practices on the cloud, creating near real-time image detection analytics with deep learning, and developing serverless architectures to aid in ETL. His most recent roles include solution architect, big data engineer, big data specialist, and instructor at Amazon Web Services. He is currently the Chief Technology Officer of Next Rev Technologies and his favorite command line program is netcat
Read more about Jason Morris

Chris McCubbin
Chris McCubbin
author image
Chris McCubbin

Chris McCubbin is a data scientist and software developer with 20 years experience in developing complex systems and analytics. He co-founded the successful big data security startup Sqrrl, since acquired by Amazon. He has also developed smart swarming systems for drones, social network analysis systems in MapReduce and big data security analytic platforms using the Apache projects Accumulo and Spark. He has been using the Unix command line starting on IRIX platforms in college and his favorite command line program is find.
Read more about Chris McCubbin

Raymond Page
Raymond Page
author image
Raymond Page

Raymond Page is a computer engineer specializing in site reliability. His experience with embedded development engendered a passion for removing the pervasive bloat from web technologies and cloud computing. His favorite command is cat.
Read more about Raymond Page

View More author details
Right arrow

It's the end of the world as we know it while and until

Let's explore two more options for assisting with iteration. The while construct allows for the repetitive execution of a list or set of commands as long as the command that controls the while loop exits successfully. Let's see an example:

Let's say I wanted to print the "hello!" string four times in a script—no more and no less. We can do so with the following:

Let's save and run this script to see what happens.

Don't forget to chmod -x these scripts to make them executable.

Executing the script produces the following:

Notice that, in the script, we created a variable called i="0". This sets the i variable to zero. Do you see the while [ $i -lt 4 ] block? This allows us to run the loop as the i variable is less than the 4 integer. Go ahead and play around with this...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Data Science with the Command Line
Published in: Jan 2019Publisher: PacktISBN-13: 9781789132984

Authors (3)

author image
Jason Morris

Jason Morris is a systems and research engineer with over 19 years of experience in system architecture, research engineering, and large data analysis. His primary focus is machine learning with TensorFlow, CUDA, and Apache Spark. Jason is also a speaker and a consultant for designing large-scale architectures, implementing best security practices on the cloud, creating near real-time image detection analytics with deep learning, and developing serverless architectures to aid in ETL. His most recent roles include solution architect, big data engineer, big data specialist, and instructor at Amazon Web Services. He is currently the Chief Technology Officer of Next Rev Technologies and his favorite command line program is netcat
Read more about Jason Morris

author image
Chris McCubbin

Chris McCubbin is a data scientist and software developer with 20 years experience in developing complex systems and analytics. He co-founded the successful big data security startup Sqrrl, since acquired by Amazon. He has also developed smart swarming systems for drones, social network analysis systems in MapReduce and big data security analytic platforms using the Apache projects Accumulo and Spark. He has been using the Unix command line starting on IRIX platforms in college and his favorite command line program is find.
Read more about Chris McCubbin

author image
Raymond Page

Raymond Page is a computer engineer specializing in site reliability. His experience with embedded development engendered a passion for removing the pervasive bloat from web technologies and cloud computing. His favorite command is cat.
Read more about Raymond Page