Join Today
+ Reply to Thread
Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By keaglez

Thread: Urgent Help: About Bash scripts...

  1. #1
    Join Date
    Aug 2007
    Location
    Tehran, Iran
    Posts
    288

    Default Urgent Help: About Bash scripts...

    Hi all, I'm a bit familiar to bash script, but I am not experienced enough to solve this problem:
    I wanna to modify last record of Cardregistery as below:
    PHP Code:
    Directory ekonsole 
    I wanna change it to:
    PHP Code:
    Directory = /mmc/mmca1/.system/QTDownLoad/ekonsole 
    (just in the last record)
    anybody can help me, please?
    Amin's Persian Gulf firmware has been updated(9/2/2010)


    "We share the same biology, regardless of ideology..."

  2. #2

    Default

    Try this? It might a little slower...
    Code:
    n=1;
    g=0;
    finish=0;
    declare -a dir;
    declare -a line;
    while test "$finish" != "1"; do
      get=`sed -n ${n}p $file`; # $file is ur card registry
      if test $(echo $get|grep "Directory = "); then
        let g++;
        dir[$g]=`echo $get|sed "s/Directory = //"`;
        line[$g]=$n;
      elif test ! "$get"; then
        finish=1;
      fi
      let n++
    done
    ## modify the last records, $g is the latest...
    sed -e "${line[g]}s:Directory = ${dir[g]}:Directory = $new_dir:" $file > /tmp/temp.txt; # the $new_dir is the new directory u wanted to replace
    if cat /tmp/temp.txt; then
      mv /tmp/temp.txt $file;
    fi
    ## try to avoid an error
    ## done
    Just for note...i havent tried this code yet...if u want to test, use a copy of card registry...
    In this code, we read the entire card registry...then assign it to array... So u can modify any Directory by number order... However, if u just want edit the "Directory = ekonsole" to "Directory = /mmc/mmca1/.system/QTDownLoad/ekonsole" just use sed...
    amin likes this.

  3. #3
    Join Date
    Aug 2007
    Location
    Tehran, Iran
    Posts
    288

    Default

    @keaglez
    unfortunately, did not worked, I created a folder and put this script and cardregistery(renamed to file) on it , but after execution, nothing happened...
    Amin's Persian Gulf firmware has been updated(9/2/2010)


    "We share the same biology, regardless of ideology..."

  4. #4
    Join Date
    Oct 2007
    Location
    Portland, OR
    Posts
    279

    Default

    Quote Originally Posted by amin View Post
    Hi all, I'm a bit familiar to bash script, but I am not experienced enough to solve this problem:
    I wanna to modify last record of Cardregistery as below:
    PHP Code:
    Directory ekonsole 
    I wanna change it to:
    PHP Code:
    Directory = /mmc/mmca1/.system/QTDownLoad/ekonsole 
    (just in the last record)
    anybody can help me, please?
    Why do you want to change it? My CardRegistry has Directory = ekonsole

  5. #5
    Join Date
    Aug 2007
    Location
    Tehran, Iran
    Posts
    288

    Default

    @PaulF
    ekonsole is sample,
    my firmware does not support attribute 4 Installation, attribute 2 Installation method needs full link patch, I wanna correct and change superman's attribute 4 method to attribute 2
    Amin's Persian Gulf firmware has been updated(9/2/2010)


    "We share the same biology, regardless of ideology..."


 
+ Reply to Thread

Similar Threads

  1. [URGENT] Plzzz help me....URGENT
    By jaiminjariwala3 in forum E6 General Chat
    Replies: 15
    Last Post: 09-01-2009, 04:29 PM
  2. Bubble Bash 2 100% Touchscreen (240x320)
    By mananwala in forum Java Games
    Replies: 2
    Last Post: 06-24-2009, 11:17 AM
  3. Bash script to read free RAM
    By aksd in forum Scripting
    Replies: 2
    Last Post: 06-11-2008, 02:11 PM
  4. Replies: 0
    Last Post: 03-29-2008, 01:25 PM
  5. missing humor in bash
    By swifty in forum Linux
    Replies: 5
    Last Post: 11-20-2007, 01:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Single Sign On provided by vBSSO

Search Engine Optimization by vBSEO 3.6.0 RC 1