Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 20 Oct 2014, 09:17
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
HowTo write column data in gtkDialog TableBox? [Solved]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Tue 09 Mar 2010, 17:05    Post subject:  HowTo write column data in gtkDialog TableBox? [Solved]  

The data for the gtkTableBox looks like this:
Code:
sda1|M|
sda3|M|
sda5||
sda6|M|
sdb1||
sdb5||
sr0||
sr1||

The sed command I`ve used before doesn`t want to do the job, ${1} is the drive (sda3):
Code:
echo "$(</tmp/drvinfo)" |sed "s/\(${1}||\).*/\1{B}/" > /tmp/drvinfo

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
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: 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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0432s ][ Queries: 11 (0.0037s) ][ GZIP on ]