I`m trying to get it to put a "B" on the end, like this: " sda3||B " and remove it: " sda3|| "
I also need to write and remove the middle position, like this: " sda3|M| " and "sda3||"
So for a given row (record) I need to write a given column (field) independantly.
I could do this in several lines of code, but I`m sure sed will probably do it in one line... Last edited by sunburnt on Thu 11 Mar 2010, 02:27; edited 1 time in total
Joined: 08 Jun 2005 Posts: 4004 Location: Arizona, U.S.A.
Posted: Thu 11 Mar 2010, 02:19 Post subject:
I didn`t find how to make sed do it in one line, but I got close...
Code:
ROW=`echo "$(<$drvINFO)" |grep $1`
COL=`echo "$ROW" |cut -d '|' -f 3`
if [ -z "$COL" ];then # set drive to boot mount
NEW="$ROW"B
echo "$(<$drvINFO)" |sed "s/$ROW/$NEW/" > $drvINFO
echo $1 >> $drvBOOT
else # set drive to not boot mount
NEW=`echo $ROW |sed 's/B//'`
echo "$(<$drvINFO)" |sed "s/$ROW/$NEW/" > $drvINFO
echo "$(<$drvBOOT)" |grep -v $1 > $drvBOOT
fi
This toggles the column data for the input file for a gtkDialog TableBox.
The TableBox reads the file $drvINFO, variables $ROW, $COL, and $NEW are obvious.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum