I'm using FreeBSD version: 11.3-RELEASE-p14, Shell version: tcsh 6.20.00 (Astron) 2016-11-24 (x86_64-amd-FreeBSD) options wide, nls, dl,al, kan, sm, rh, color, filec and trying to use cut to harvest fields in a string variable, with no success.
If I comment out the
#! /bin/sh . # Variables filelength=0 start=0 reachability="" . filelength=$(sed -n '$=' /$workdir/ntpstatus.txt) start=3 tr -s ' ' < /$workdir/ntpstatus.txt > /$workdir/ntpstatus2.txt while [ "$start" -le "$filelength" ] do peer_line=echo sed -n $start,1p /$workdir/ntpstatus2.txt echo $peer_line reachability=$(cut -d " " -f 2 $peer_line) echo $reachability start=$(( start + 1 )) done
reachability=line, it happily prints out the 3 whole lines from the file ntpstatus2.txt, so string variable
peer_lineis reading a line from the file ntpstatus2.txt fine. But I can't for the life of me get the string variable
reachabilityto equal field 2 of the string variable
peer_line. I've tried adjusting
-oLto no avail. I've tried just about every combination of cut(1) parameters I can find on the web. Sample of
1 40822 94fa yes yes none candidate sys_peer 15. I've been at this for nearly two days now and I'm losing the will. Could someone please point me in the right direction?