Reputation: 3310
Does cat command load the entire file into main memory?
for i in `cat file.txt`; do
# some logic on i
done
Will this code has any performance issue when the file is large say 5-6 GB?
Upvotes: 1
Views: 1374
Reputation: 31768
cat
doesn't load the whole file in, but the process substitution in your for loop above will
If you have one entry per line you could instead:
while read line;
# some logic on $line
done < file.txt
Upvotes: 3