1. I got this script I wrote in Linux, and finding out, I need absolute path to bash?
Having to change my scripts from #!/bin/bin to #!/usr/local/bin/bash
is there a way to put bash in the path so to not have to change all of my scripts like that?
more importantly.
this one script I wrote in Linux has a call to sed, and I get this error.
when this scripts calls changePrams in that function is uses the runscript= path and it looks like it has a length issue? Because it only gets to half of the path it needs to look into to call that other script to put it into play to sed it so it can change/update a pram within that script before it gets called to run again.
I have no idea the why behind this.
Having to change my scripts from #!/bin/bin to #!/usr/local/bin/bash
is there a way to put bash in the path so to not have to change all of my scripts like that?
more importantly.
this one script I wrote in Linux has a call to sed, and I get this error.
Code:
$ fetchwp
sed: 1: "/home/userx/bin/usersta ...": invalid command code u
when this scripts calls changePrams in that function is uses the runscript= path and it looks like it has a length issue? Because it only gets to half of the path it needs to look into to call that other script to put it into play to sed it so it can change/update a pram within that script before it gets called to run again.
I have no idea the why behind this.
Code:
#!/usr/local/bin/bash
runscript="$HOME/bin/userstartups/wallhaven.sh"
ResizeImages=$HOME/bin/userstartups/resizeImages
PathToImages=$HOME/Images/wallhaven-papers
SaveNumber=$PathToImages/.savenumber
mkdir -p $PathToImages
#to pick up where it left off on a next run
touch "$SaveNumber"
[[ -f "$SaveNumber" ]] && { x=$(cat "$SaveNumber") ; } || { x=1 ; }
DealWithAmountOfImages()
{
workingFile1=$HOME/.RemoveImages1
workingFile2=$HOME/.RemoveImages2
touch $workingFile1 $workingFile2
sizeOfDir=$(du -sh $PathToImages | awk '{print $1}')
num=${sizeOfDir::-1}
#if greater than 500 MB of files, remove half of that amount
[[ $num -gt '500' ]] &&
{ amountOfFiles=$( find $PathToImages \( -type f -iname "*.jpg" -o -type f -iname "*.png" \) | wc -l) ;
find $PathToImages \( -type f -iname "*.jpg" -o -type f -iname "*.png" \) >> $workingFile1 ;
cat $workingFile1 | shuf > $workingFile2 ;
while read f
do
rm "$f"
[[ $((d++)) -eq $((amountOfFiles/2)) ]] && break
done < $workingFile2 ; } ||
{ echo "
Nothing to be done.
$(du -sh $PathToImages | awk '{print $1}')" ; }
#reset d
d=0
}
changePrams()
{
sed -i '/^STARTPAGE/s/\(^S.*\)/STARTPAGE='$x'/' "$runscript"
x=$((x>64?0:x+2))
#save last number used
echo "$x" > "$SaveNumber"
}
#frist run
changePrams
"$runscript"
#sleep 1
#"$ResizeImages" "$PathToImages"
echo "out-and going into while loop."
while sleep 1800
do
changePrams
#echo "ran $x"
"$runscript"
# sleep .5
DealWithAmountOfImages
"$ResizeImages" "$PathToImages"
done