This is an interesting bash scripting trick. This allows deleting the first 10 lines from a text file, but keeping the rest of the file instead of deleting it.
X=10 file="file.txt" # read the file, line by line while read -r line; do # add current line to array # (you can modify this to do whatever you want) links+=($line) # delete first line in file sed -i "1,1 d" $file # decrement X : $((X--)) # if it reached 0, break out of the loop ((X<1)) && break done < $file |
Use it on a text file and then it will work on the file, but not delete it. I guess this could be useful, iterating through files and deleting the contents. So this is a good example of bash scripting.