Simplify line_count and pick_fields

This commit is contained in:
root 2013-01-06 21:58:04 -08:00
parent 3cddb977c4
commit 6fb48d0eea

View file

@ -85,16 +85,14 @@ append_to()
# $2 input value # $2 input value
pick_fields_1_2() pick_fields_1_2()
{ {
local f_ret= f_line= f_var= f_oifs="$IFS" IFS= local f_ret= f_one= f_two=
f_var=$1 while read f_one f_two _ # from << here-document
IFS=$Newline
for f_line in $2
do do
IFS=$f_oifs f_ret="$f_ret$f_one $f_two$Newline"
set -- $f_line done <<EOF
f_ret=$f_ret"${1:-} ${2:-}"$Newline $2
done EOF
setvar "$f_var" "${f_ret#$Newline}" setvar "$1" "${f_ret#$Newline}"
} }
# Take all lines matching $2 (full line) # Take all lines matching $2 (full line)
@ -118,13 +116,10 @@ filter_to()
# Output the number of lines in $1 # Output the number of lines in $1
line_count() line_count()
{ {
local f_x=0 IFS= local IFS=
IFS=$Newline IFS=$Newline
for f_line in $1 set -- $1
do xecho "$#"
f_x=$(($f_x + 1))
done
xecho "$f_x"
} }