wget -r -l1 www.lingarogroup.com/about-us
cd www.lingarogroup.com # use TAB completion
Done by the shell, before it gets to the command:
echo c*
Same as:
echo careers cloud-solutions computer-vision consumer_reasearch
Let's view all images together: find
find -name '*.png'
Note quoting of '*' here. Compare
echo c*
echo 'c*'
Loop over results
for f in a b c;do echo "val: $f"; done
So:
for f in $(find -name '*.png');do echo f=$f ;done
Note: f
is a variable.
for f in $(find -name '*.png');do
echo $f|cut -c3-|tr / _ ;
done
See help:
cut -h
cut --help
man cut
Assign the new name to variable:
for f in $(find -name '*.png');do
name=$(echo $f|cut -c3-|tr / _ );
echo "$f -> $name"
done
Note " quoting. It allows for variable expantion. Needed here because > is redirect. Needs to be passed to echo
, not interpreted by shell.
for f in $(find -name '*.png');do
name=$(echo $f|cut -c3-|tr / _ );
ln -s "$f" "$name"
done
ls
pcmanfm # file browser
rm *.png
code img.sh
img.sh:
#!/bin/bash
for f in $(find -name '*.png');do
name=$(echo $f|cut -c3-|tr / _ );
ln -s "$f" "$name";
done
Set executable flag:
chmod +x img.sh
Expand the script
#!/bin/bash
set -e #2
mkdir -p out #1, #3: -p
for f in $(find -name '*.png');do
name=$(echo $f|cut -c3-|tr / _ )
ln -s "../$f" "out/$name"; #1
done
find www.lingarogroup.com/ -name '*.png'|grep -v 18/02 | xargs rm -v
X=1
touch 1 2 "3 4"
touch X1=$X "X2=$X" 'X3=$X'
touch 'date: `date`'
touch "date: `date`"
[abc]
^begin and end$
.
a*
cat|dog
[a-z][0-9]
bash -x
#variables
X=1
xterm
export Y=1
date=`date +%Y%m%d`
echo app-$date.log
X=20
echo "width $Xpx"
echo "width ${X}px"
-z ""
-f file
-d dir
! -z "$x"
if [ ]
if [[ ]]
if (( ))
#!/bin/bash
set -eu
cd `dirname $0`
out=${1:-}
if [ -z "$out" ];then
echo "Usage: $0 [output-dir]"
exit 1
fi
mkdir -p ${out}
for f in $(find -name '*.png');do
name=$out/$(echo $f | cut -c3-| tr / -)
if [ -e "$name" ];then
echo "Already exists $(basename $f)"
else
ln -s "../$f" "$name"
fi
done
http://redsymbol.net/articles/unofficial-bash-strict-mode/
http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming
https://kvz.io/blog/2013/11/21/bash-best-practices/
https://www.regular-expressions.info/quickstart.html