Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

How to do it...

This Bash script will generate an HTML album page:

#!/bin/bash 
#Filename: generate_album.sh 
#Description: Create a photo album using images in current directory 

echo "Creating album.." 
mkdir -p thumbs 
cat <<EOF1 > index.html 
<html> 
<head> 
<style> 

body  
{  
  width:470px; 
  margin:auto; 
  border: 1px dashed grey; 
  padding:10px;  
}  

img 
{  
  margin:5px; 
  border: 1px solid black; 

}  
</style> 
</head> 
<body> 
<center><h1> #Album title </h1></center> 
<p> 
EOF1 

for img in *.jpg; 
do  
  convert "$img" -resize "100x" "thumbs/$img" 
  echo "<a href=\"$img\" >" >>index.html 
  echo "<img src=\"thumbs/$img\" title=\"$img\" /></a>" >> index.html 
done 

cat <<EOF2 >> index.html 

</p> 
</body> 
</html> 
EOF2  

echo Album generated to index.html 

Run the script as follows: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985