Sponsored Content
Top Forums Shell Programming and Scripting Suggestions for command line parsing Post 302825557 by radoulov on Monday 24th of June 2013 03:03:28 PM
Old 06-24-2013
And another one:
Code:
perl -le'
  ($_ = shift) =~ 
    s/(-?\d+)-(-?\d+)/
    join ",", $1 > $2 ? reverse @{[$2..$1]} : @{[$1..$2]}
    /xeg;
  print
  ' -- <your_string>

Code:
% perl -le'
  ($_ = shift) =~
    s/(-?\d+)-(-?\d+)/
    join ",", $1 > $2 ? reverse @{[$2..$1]} : @{[$1..$2]}
    /xeg;
  print
  ' -- 9-12,19-15,20-20,0--5,-1-2,-5--1
9,10,11,12,19,18,17,16,15,20,0,-1,-2,-3,-4,-5,-1,0,1,2,-5,-4,-3,-2,-1


Last edited by radoulov; 06-24-2013 at 05:11 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Parsing the command line arguments

Is there a way to get the command line arguments. I am using getopt(3) but if the arguments are more than one for a particular option than it just ignores the second argument. For eg ./a.out -x abc def now abd will be got with -x using getopt "( x : )" and string abc\0def will get stored... (7 Replies)
Discussion started by: jayakhanna
7 Replies

2. UNIX for Dummies Questions & Answers

command line argument parsing

how to parse the command line argument to look for '@' sign and the following with '.'. In my shell script one of the argument passed is email address. I want to parse this email address to look for correct format. rmjoe123@hotmail.com has '@' sign and followed by a '.' to be more... (1 Reply)
Discussion started by: rmjoe
1 Replies

3. Shell Programming and Scripting

parsing command line switches in Perl

Hi, My perl script takes few switches which i'm parsing through GetOpt::Long module. My script looks like something : myscript.pl --file="foo" --or --file="bar" The --file switch takes 2 arguments foo and bar. The 2 values of file are separated by --or switch. I want to ensure that... (1 Reply)
Discussion started by: obelix
1 Replies

4. Shell Programming and Scripting

Help parsing command line arguments in bash

Looking for a little help parsing some command line arguments in a bash script I am working on, this is probably fairly basic to most, but I do not have much experience with it. At the command line, when the script is run, I need to make sure the argument passed is a file, it exists in the... (3 Replies)
Discussion started by: Breakology
3 Replies

5. Shell Programming and Scripting

Parsing a command line parameter in script

I have a simple script that builds a complex program call which passes a number of parameters to the program. I'm trying to enhance the script to include the value of the command line parameter in the name of a file being created. The problem I'm having is that the parameter may include a forward... (11 Replies)
Discussion started by: pbmax626
11 Replies

6. Programming

Parsing command line arguments in Python

Hi, I've a python script called aaa.py and passing an command line option " -a" to the script like, ./aaa.py -a & Inside the script if the -a option is given I do some operation if not something else. code looks like ./aaa.py -a . . if options.a ---some operation--- if not options.a... (1 Reply)
Discussion started by: testin
1 Replies

7. Shell Programming and Scripting

Parsing Command Line Arguments In C shell script

]I have a string like "/abc/cmind/def/pq/IC.2.4.6_main.64b/lnx86" and this string is given by user. But in this string instead of 64b user may passed 32 b an i need to parse this string and check wether its is 32b or 64 b and according to it i want to set appropriate flags. How will i do this... (11 Replies)
Discussion started by: codecatcher
11 Replies

8. Shell Programming and Scripting

awk command suggestions

I've defined the order of elements which needs to be print in a order in a variable. please let me know how can I use it in awk command ... (2 Replies)
Discussion started by: BrahmaNaiduA
2 Replies

9. Shell Programming and Scripting

Command Line Perl for parsing fasta file

I would like to take a fasta file formated like >0001 agttcgaggtcagaatt >0002 agttcgag >0003 ggtaacctga and use command line perl to move the all sample gt 8 in length to a new file. the result would be >0001 agttcgaggtcagaatt >0003 ggtaacctga cat ${sample}.fasta | perl -lane... (2 Replies)
Discussion started by: jdilts
2 Replies

10. Shell Programming and Scripting

Parsing XML using command line

Hi Experts, How do I parse a XML with below contents <saw:user name="mbussey@xyz.com" /> <saw:user name="kimmy.chan@pqr.com" /> <saw:user name="chudgins@gmail.com" /> and retrieve below output ? mbussey@xyz.com kimmy.chan@pqr.com chudgins@gmail.com ... (17 Replies)
Discussion started by: pauldx
17 Replies
QXmlSimpleReader(3qt)													     QXmlSimpleReader(3qt)

NAME
QXmlSimpleReader - Implementation of a simple XML reader (parser) SYNOPSIS
#include <qxml.h> Inherits QXmlReader. Public Members QXmlSimpleReader () virtual ~QXmlSimpleReader () virtual bool parse ( const QXmlInputSource * input, bool incremental ) virtual bool parseContinue () DESCRIPTION
The QXmlSimpleReader class provides an implementation of a simple XML reader (parser). This XML reader is sufficient for simple parsing tasks. The reader: provides a well-formed parser; does not parse any external entities; can do namespace processing. Documents are parsed with a call to parse(). See also XML. MEMBER FUNCTION DOCUMENTATION
QXmlSimpleReader::QXmlSimpleReader () Constructs a simple XML reader with the following feature settings: <center>.nf </center> More information about features can be found in the Qt SAX2 overview. See also setFeature(). QXmlSimpleReader::~QXmlSimpleReader () [virtual] Destroys the simple XML reader. bool QXmlSimpleReader::parse ( const QXmlInputSource * input, bool incremental ) [virtual] Reads an XML document from input and parses it. Returns FALSE if the parsing detects an error; otherwise returns TRUE. If incremental is TRUE, the parser does not return FALSE when it reaches the end of the input without reaching the end of the XML file. Instead it stores the state of the parser so that parsing can be continued at a later stage when more data is available. You can use the function parseContinue() to continue with parsing. This class stores a pointer to the input source input and the parseContinue() tries to read from that input souce. This means you should not delete the input source input until you've finished your calls to parseContinue(). If you call this function with incremental TRUE whilst an incremental parse is in progress a new parsing session will be started and the previous session lost. If incremental is FALSE, this function behaves like the normal parse function, i.e. it returns FALSE when the end of input is reached without reaching the end of the XML file and the parsing cannot be continued. See also parseContinue() and QSocket. Examples: bool QXmlSimpleReader::parseContinue () [virtual] Continues incremental parsing; this function reads the input from the QXmlInputSource that was specified with the last parse() command. To use this function, you must have called parse() with the incremental argument set to TRUE. Returns FALSE if a parsing error occurs; otherwise returns TRUE. If the input source returns an empty string for the function QXmlInputSource::data(), then this means that the end of the XML file has been reached; this is quite important, especially if you want to use the reader to parse more than one XML file. The case of the end of the XML file being reached without having finished parsing is not considered to be an error: you can continue parsing at a later stage by calling this function again when there is more data available to parse. This function assumes that the end of the XML document is reached if the QXmlInputSource::next() function returns QXmlInputSource::EndOfDocument. If the parser has not finished parsing when it encounters this symbol, it is an error and FALSE is returned. See also parse() and QXmlInputSource::next(). SEE ALSO
http://doc.trolltech.com/qxmlsimplereader.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qxmlsimplereader.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QXmlSimpleReader(3qt)
All times are GMT -4. The time now is 02:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy