Sponsored Content
Full Discussion: Understanding sed
Top Forums Shell Programming and Scripting Understanding sed Post 302774009 by Scrutinizer on Friday 1st of March 2013 04:06:20 AM
Old 03-01-2013
Hi, the first one deletes the second field only if it consists of one character... It replace the first field and a colon + a character and a colon with the first field (that was captured with \( .. \) and recalled by\1) and two colons

The second replaces any number of non-colons and a colon by a colon, the number two means the it does this with the second occurrence on a line...
This User Gave Thanks to Scrutinizer For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

need further understanding of init.d

I needt o know how what init.d does and how it knows which dameons/applications to turn off and how to restart the applications after reboot. any OS - solaris/hp-ux (1 Reply)
Discussion started by: jigarlakhani
1 Replies

2. Shell Programming and Scripting

understanding the sed command

Guys, I am trying to understand the sed command here. adx001 $ a=/clocal/dctrdata/user/dctrdat1/trdroot/recouncil adx001 $ b=`echo $a | sed 's/\//\\\\\//g'` adx001 $ echo $b \/clocal\/dctrdata\/user\/dctrdat1\/trdroot\/recouncil The sed command i took it from the script. Please... (3 Replies)
Discussion started by: mac4rfree
3 Replies

3. UNIX for Dummies Questions & Answers

Help understanding sed

I am trying to create a basic script that converts an Oracle script into a Sybase script. The only things im changing are Datatypes and the to_char and to_date functions. I am not really 100% sure of the way it works. I have tried running the functions through a loop to replace each word line... (6 Replies)
Discussion started by: Makaer
6 Replies

4. Shell Programming and Scripting

need help understanding mv

I just started shell coding and I'm a bit confused on how 'mv' works can someone explain to me how it works and if i did this correctly. Thanks. echo "Enter Name of the first file:" read file1 #echo $file1 if ; then echo "Sorry, file does not exist." exit 1 ... (16 Replies)
Discussion started by: taiL
16 Replies

5. UNIX for Dummies Questions & Answers

understanding {%/*}/

Hi Gurus: I am trying to understand the following line of code.I did enough of googling to understand but no luck.Please help me understand the follow chunk of code: X=$0 MOD=${X%/*}/env.ksh X is the current script from which I am trying to execute. Say if X=test.ksh $MOD is echoing :... (3 Replies)
Discussion started by: vemana
3 Replies

6. UNIX for Dummies Questions & Answers

understanding sed command

Hi Friends, I need a small help in understanding the below sed command. $ cat t4.txt 1 root 1 58 0 888K 368K sleep 4:06 0.00% init 1 root 1 58 0 888K 368K sleep 4:06 0.00% init last $ sed 's/*$//' t4.txt 1 root 1 58 0 888K ... (3 Replies)
Discussion started by: forroughuse
3 Replies

7. Shell Programming and Scripting

help understanding regex with grep & sed

I have the following line of code that works wonders. I just don't completely understand it as I am just starting to learn regex. Can you help me understand exactly what is happening here? find . -type f | grep -v '^\.$' | sed 's!\.\/!!' (4 Replies)
Discussion started by: trogdortheburni
4 Replies

8. Shell Programming and Scripting

Need your help in understanding this

Hi, I found this in a script and I would like to know how this works Code is here: # var1=PART1_PART2 # var2=${var1##*_} # echo $var2 PART2 I'm wondering how ##* makes the Shell to understand to pick up the last value from the given. (2 Replies)
Discussion started by: sathyaonnuix
2 Replies

9. Shell Programming and Scripting

Need Quick help on Understanding sed Regex

Hi Guys, Could you please kindly explain what exactly the below SED command will do ? I am quite confused and i assumed that, sed 's/*$/ /' 1. It will remove tab and extra spaces .. with single space. The issue is if it is removing tab then it should be Î right .. please assist.... (3 Replies)
Discussion started by: Nandy
3 Replies
ggParseOptions(3)							GGI							 ggParseOptions(3)

NAME
ggParseOptions - Option parsing SYNOPSIS
#include <ggi/gg.h> char *ggParseOptions(const char *str, gg_option *optlist, int count, int flag); DESCRIPTION
ggParseOptions parses a string str of options in LibGG's option format and places the results in the ".name" members of the optlist. The parameter count specifies the length of optlist. The parameter flags is a bitwise or of values that alter behavior, the only one defined at this time being GG_PARSEOPTS_ALLOW_UNKNOWN, which, if present, will cause ggParseOptions to ignore options found in the string for which there are no matching entries in optlist (normally this generates a failure and a warning message). The normal LibGG option format is defined as follows: A colon or whitespace is the separator between options. Option names consist of any character except parenthesis, colons, whitespace characters, the equals sign ('=') and the NULL ('0') charac- ter. Option values may consist of any character except the NULL character, however in order to include colons, whitespace characters, or paren- thesis, the option must be quoted. Option values that begin with a single or double quote are considered to be quoted, and must end with the same quote character with which they began. The quotes are not considered to be part of the option value. In order to include the quote character in use in a quoted option value it must be escaped by a backslash ('') character. Backslashes always escape, even in unquoted values, and so must always be escaped with a backslash in order to be included. Named options begin with a dash (-) character followed by an option name and may be boolean (present or not) or may contain an equal sign to assign the option a string value (everything following the equal sign up to the next forbidden character as described above.) Matching is case sensitive, but options can be abbreviated right down to a single letter as long as the name remains unique among the entries in optlist and the GG_PARSEOPTS_ALLOW_UNKNOWN flag is not used. Unnamed options do not (duh) have a name field and are positionally mapped to entries in optlist. Unnamed options are processed after the first option field not starting with a dash is encountered, and occupy the rest of the option string. They are assigned to any unnamed- eligible options (see below) in the order they appear in optlist, but if any were previously discovered in named form they forfeit their position in that order. Options that are eligible to be used in an unnamed fashion must have a colon or dash prefixed to their optname in the optlist when ggParseOptions is invoked. Unnamed options may appear as named options as well. ggParseOptions will alter the first character in the cor- responding optname entry in optlist to a colon or to a dash depending on whether the option was present in unnamed or named form, respec- tively. Thus the caller can determine whether the option was presented in named or unnamed form. Options that appear in boolean form will have the first character in their result changed to "y". This can be distinguished from an explicit value of "y" because no NULL terminator is appended to the "y". Options that are not found are left unaltered in optlist. Option names and values in str are limited in length to GG_MAX_OPTION_NAME and GG_MAX_OPTION_RESULT bytes, respectively, including one byte for a terminating NULL character. RETURN VALUE
ggParseOptions returns the position in str after the last character of a valid option string, or NULL if str was determined not to be a valid option string. Even on failure, the contents of optlist may have been altered. libgg-1.0.x 2005-08-26 ggParseOptions(3)
All times are GMT -4. The time now is 02:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy