User Tools

Site Tools


bash:files:read_a_file:skip_reading_comments

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bash:files:read_a_file:skip_reading_comments [2021/01/26 13:41] – created peterbash:files:read_a_file:skip_reading_comments [2021/01/26 13:42] (current) peter
Line 1: Line 1:
 ====== BASH - Files - Read a file - Skip Reading Comments ====== ====== BASH - Files - Read a file - Skip Reading Comments ======
 +
 +To avoid reading comments starting with hash, **#**, simply skip them inside the loop:
 +
 +<code bash>
 +while read -r line; do
 +  [[ $line = \#* ]] && continue
 +  printf '%s\n' "$line"
 +done < "$file"
 +</code>
 +
 +----
  
bash/files/read_a_file/skip_reading_comments.1611668488.txt.gz · Last modified: 2021/01/26 13:41 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki