Ask questions and share hosting deals.
New here? Register and read our Community Rules. Accounts are approved by hand.
Im Trying to loop though a file line by line and run some commands based on input. Where im struggling is
while read line;do echo $line; done < item.txt
misses the first line each time. Is there something wrong with the command ?
@exussum That works fine for me and reads the first line.
That's exactly how it's supposed to be too.
while read LINE ; do echo $LINE done < my.file
exussum@exussumuk:~$ cat item.txt 13358 13359exussum@exussumuk:~$ bash test.sh 13358
is what i get. cat shows item.txt having 2 lines
looking at it now, it seems the item.txt is broken.
@exussum Try this..
for LINE in $(cat item.txt) ; do echo $LINE done
something like this should work as well...
cat item.txt | while read LINE; do echo $LINE done < my.file
Comments
@exussum That works fine for me and reads the first line.
That's exactly how it's supposed to be too.
is what i get. cat shows item.txt having 2 lines
looking at it now, it seems the item.txt is broken.
@exussum Try this..
something like this should work as well...
cat item.txt | while read LINE; do
echo $LINE
done < my.file