Wednesday, March 1, 2017

Bash Scripting: # changing the IFS value

#!/bin/bash
#
# changing the IFS value
#
IFS=$'\n'
#
for entry in $( cat /etc/passwd )
do
        echo "Values in $entry -"
        IFS=:
        for value in $entry
        do
                echo "  $value"
        done
done
#
#



Results:



Values in root:x:0:0:root:/root:/bin/bash -
        root
        x
        0
        0
        root
        /root
        /bin/bash


[...]


No comments:

Post a Comment