I am trying to make a small script that will give me the File names without the $2
first and $3
last names in a $1
directory
I have this code
#!/bin/bash
TOTFILES=find "$1" -maxdepth 1 -type f -exec basename {} ';' | wc -l
find "$1" -maxdepth 1 -type f -exec basename {} ';' | sort |
head -n (( TOTFILES-$3 )) | tail -n (( TOTFILES-$3-$2 ))
My main problem is that I can't assign TOTFILES with the output of that long line.
I think if I can get that value assigned, it will work (hopefully) :)
PS: I don't know if I used
(( TOTFILES-$3 ))
right, to get the value.
Thanks for the fast answer.
Now I get a new problem; I guess (( ))
is not the right way to get number
./middleFiles: line 5: syntax error near unexpected token `('
./middleFiles: line 5: `find "$1" -maxdepth 1 -type f -exec basename {} ';' | sort | head -n (( TOTFILES-$3 )) | tail -n (( TOTFILES-$3-$2 ))'