DBZoo DBZoo
  • Tools
    • Site Tools
    • Recent Changes
    • Media Manager
    • Sitemap
    • Page Tools
    • Show pagesource
    • Old revisions
    • Backlinks
    • Back to top
  • Log In

  1. Trace
  2. readdelimfile

blog:readdelimfile

Site Navigator

Site Navigator

  • Home Page
  • Blog, Archive
  • Active Projects
    • Livebox
    • Atmel
    • Cybiko
    • nslu
    • istar
  • Shop & Forums
andriod apache arduino atmel avr bascom cable control csharp cybiko discussion ds18b20 esx firmware freenas giant graphite h8 hardware java lcd linux linux_ex475 livebox macosx mail microcode milling modem mp3 nas network nmt nslu2 openvpn oracle plex plsql printer programming pv python scala schematics shell toolchain video whs windows xap

  • Show pagesource
  • Old revisions
  • Backlinks
  • Share on ...
  • Google+
  • Twitter
  • LinkedIn
  • Facebook
  • Pinterest
  • Telegram

Read a Delimited File

How can you read a row in delimited file and get each field value into a separate variable?

#!/usr/bin/bash
 
IFS=":"
while read f1 f2 f3; do
  echo "$f1-$f2-$f3"
done < delim.txt

Using the following input file as a sample:

field1:field2:field3
field1a:field2a:field3a

Sample run:

$ ./delim.sh
field1-field2-field3
field1a-field2a-field3a
shell, programming
  • blog/readdelimfile.txt
  • Last modified: 2009/11/27 17:53
  • (external edit)
Built with Bootstrap 3 Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki