I'm trying to do specific operations in a file, defining the index on 1 and doing operations line-by-line, deleting the contents of line with sed -i -e "{a}d" file as they go
the problem is it only seems to be downloading the line 1 by one, for example, on a file with
1
2
3
4
5
the result is 2 3 5, so only downloading 1 and 4. What am I doing wrong?
#!/usr/bin/bash
a=0
filename="$1"
while read -r line; do
echo $a
name="$line"
Operation
sed -i -e "${a}d" $1
let a+=1
done < "$filename"
From comment: What I intent to do is:
- Echo the current line it's on
- Performs an operation on the file (in this case wget)
- Delete the line it just downloaded
- Increase the current line
- Until there are no more lines
n, you will not delete line that wasnin the original data.