Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2013oct27 Language: Bash OS: Linux Q. Can I parse a file without awk (or other external program)? A. Sure, bash is very powerful. One way is to set the IFS (Inter Field Separator). Its normally whitespace characters. Its good to set it back when you are done. Here's an example:#!/bin/sh OLD_IFS=$IFS IFS=: cat /etc/passwd | while read LINE; do set - $LINE username=$1 password=$2 userid=$3 groupid=$4 humanname=$5 home=$6 shell=$7 done IFS=$OLD_IFS
Add a commentSign in to add a comment