How to use Internal Field Separator correctly?

I am trying to set the IFS to ‘:’, but it seems to not work. Here is my code, FILE="/etc/passwd" while IFS=’:’ read -r line; do set $line echo $1 done < $FILE When I run my code, it seems to give me the entire line. I have used the set command to assign positional… Read More How to use Internal Field Separator correctly?

I am using the ifstream function in c++ and I need to save two words as one string instead of splitting them

I need to read in a line from a file in c++ but need to save two strings as one. For example, if the the files line had someones name like Bernie Sanders, I would want to save the entire name into a string variable instead of just the first name. >Solution : I assume… Read More I am using the ifstream function in c++ and I need to save two words as one string instead of splitting them

How do I extract two different keywords from two different lines in a file in bash shell?

I have a file called data.txt. when I read the file, the content looks like the below. $ cat data.txt name: linuxVol id: 6 type: Linux dir excludes: .snapshot* ~snapshot* .zfs .isilon .ifsvar .lustre inode: 915720 free_space: 35.6TiB (auto) total_capacity: 95.0TiB (auto) number_of_files: 5,789,643 number_of_dirs: 520,710 mounts: https://server1.example.com:30002: /mnt/tube How can I extract keywords Linux… Read More How do I extract two different keywords from two different lines in a file in bash shell?