w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
read line and remove newline character using shell script

You probably generated the text file on a windows machine or some other setting with dos line endings. You can fix that by either

  • converting the file to unix line endings with dos2unix
  • deleting ' ' characters: cat $FILE | tr -d ' ' | while read LINE ...
  • use a utility like awk to grab the first field: cat $FILE | awk '{print $1}' | while read LINE ...

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.