tcsh reading columns of a text file into variables -
i have text file in looks like:
jose santiago:385-898-8357:385-555-5555:38 fife way, abilene, tx 39673:1/5/58:95600 tommy savage:408-724-0140:408-777-0121:1222 oxbow court, sunnyvale, ca 94087:5/19/66:34200 yukio takeshida:387-827-1095:387-888-1198:13 uno lane, ashville, nc 23556:7/1/29:57000 vinh tranh:438-910-7449:438-999-0000:8235 maple street, wilmington, vm 29085:9/23/63:68900
i trying write tcsh script read text file , assign each colon delimited field variable, exception of name, want set 2 separate variables. have tried several things, can't work. i'm sorry, i'm novice. in advance help.
supposing name variable have 2 words separated space, first replace space :
, use cut field variables:
sed 's/ /:/' <filename >new_file set var1 = `cut -f1 -d ':' new_file` set var2 = `cut -f2 -d ':' new_file` set var3 = `cut -f3 -d ':' new_file`
etc... each field in file
ps: if don't mind rewriting original file, can replace inline:
set -i.bak 's/ /:/' filename
Comments
Post a Comment