Parsing values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing values
# 1  
Old 10-28-2012
Parsing values

can anybody tell me why this code does not work?

Code:
 
cat x1.ksh
 
#!/bin/ksh
set -x
echo "|$#|"
while [ $# -gt 0 ]
do
     case $1 in
      --+([kK])
          shift
          K=$1
          ;;
       *)
         echo "Here I am"
         shift
         ;;
   esac
done

./x1.ksh -k 5+ echo '|2|'
|2|
./x1.ksh: line 5: syntax error at line 10: `newline' unexpected

Thanks to all who answer

---------- Post updated at 04:40 PM ---------- Previous update was at 02:40 PM ----------

got it...


Code:
 
 
#!/bin/ksh
set -x
echo "|$#|"
while [ $# -gt 0 ]
do
   case $1 in
      -+([kK]))
          shift
          K=$1
          ;;
        *)
          shift ;;
    esac
done

This User Gave Thanks to BeefStu For This Post:
# 2  
Old 10-28-2012
Thanks for posting your solution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing Comma Separated values to UNIX variable from PLSQL

Hi All, I'm trying to pass the comma separated values (string) returned from Plsql Procedure to UNIX variable. getting the below log message cat: -: Bad file descriptor awk: cmd. line:1: fatal: error reading input file `-': Bad file descriptor The output coming from plsql procedure is... (3 Replies)
Discussion started by: Mahesh3089
3 Replies

2. Shell Programming and Scripting

Parsing Column Values in Row

Hi , I have been trying to write a awk script which will have the following Output 1. Append the last Characters of the lines matching pattern xxxxxxxxx & then a space & then Append the last Characters of the lines matching pattern yyyyyyyyy 2. the process will continue till end of file &... (10 Replies)
Discussion started by: newageBATMAN
10 Replies

3. Shell Programming and Scripting

Needs help in parsing comma separated values

hello experts, i am retrieving values in variables jobKey and jobName within my shell script. these values are returned to me within braces and i am using following command to remove those braces: jobKeys=`echo $jobKeys | sed 's:^.\(.*\).$:\1:'` jobNames=`echo $jobNames | sed... (1 Reply)
Discussion started by: avikaljain
1 Replies

4. Shell Programming and Scripting

Parsing common values across multiple files

Hi All, I have multiple (5+) text files with single columns and I would like to grep the common values across all the text files and parse it to a new file. All the values are numerical. Please let me know how to do it using awk. (6 Replies)
Discussion started by: Lucky Ali
6 Replies

5. Shell Programming and Scripting

Parsing Values from XML

Hi all, Can anyone help me out in parsing values from the xml in shell script below.. <DropDB> <DBName>RMDatabase</DBName> <UName>root</UName> <PWord>test</PWord> </DropDB> I need the values RMDatabase , root and test alone ... :wall: Thanks in advance :) ... (2 Replies)
Discussion started by: selvarajvs
2 Replies

6. Shell Programming and Scripting

parsing values

I have a big file with the following format "57:24,A:1,B:5,C:7,D:10)" "42:24,A:2,B:6,C:4,D:5)" "45:34,A:1,B:7,C:5,D:6)" every row has the same characters. I want to parse out the values seen after each of the character followed by ':' into a tab delimited file of the following format ... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

7. Shell Programming and Scripting

parsing df column values

Hi all, I need to run df, and parse the value under column of "Mounted on" For instance, my df is Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 4881344 4106460 526924 89% / none 245164 220 244944 1% /dev... (6 Replies)
Discussion started by: peuceul
6 Replies

8. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

9. Shell Programming and Scripting

Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w $ip = "$ARGV"; $rw = "$ARGV"; $snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw"; $snmpw = "/usr/local/bin/snmpwalk -Os -c $rw"; $syst=`$snmpg $ip system sysName sysObjectID`; sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies

10. Shell Programming and Scripting

Parsing and getting values of variables

suppose i have a file value where it returns 3 values a=1 b=2 c=4 when i run it. i am using this file in my shell script. how do i parse and get the value of a b and c? (3 Replies)
Discussion started by: Rekha
3 Replies
Login or Register to Ask a Question