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 Sat 25 Oct 2014, 18:59
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 Posts_count  
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...

Edited_time_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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0436s ][ Queries: 12 (0.0033s) ][ GZIP on ]