Sponsored Content
Top Forums Shell Programming and Scripting Can BASH handle mathematical operations and do a Search & Replace? Post 302489944 by vgersh99 on Saturday 22nd of January 2011 08:43:27 PM
Old 01-22-2011
something along these line:
nawk -f jl.awk myFile.xml

jl.awk:
Code:
match($0,"margin-right:[^;][^;]*") {
    str=substr($0,RSTART,RLENGTH)
    gsub("[^0-9]","",str)
    str-=(str/4)
    $0=substr($0,1,RSTART-1) "margin-right:" str "px;" substr($0,RSTART+RLENGTH+1)
}
1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help, sed search&replace

Plzzzz, tell me some script about this... What does this mean ? sed '/^ */s///' sed '/^/s// /' and why it's diferent ??? sed '/ */s// /g' and sed 's/ */ /g'. It's all the same ??? Thanks you very much (2 Replies)
Discussion started by: mle
2 Replies

2. Shell Programming and Scripting

Search & replace

Is there any way we can achieve search & replace with awk? I could achieve the same with sed in following way - sed 's/A/B/g' file1 > file2 But the same regex if I try with using awk following way, awk 's/A/B/g' file1 > file2 it gives me Syntax error. I strongly believe I am... (1 Reply)
Discussion started by: videsh77
1 Replies

3. Shell Programming and Scripting

search & replace in variable

Can I use search & replace in any variable? Suppose I have one variable named var1 which holds value "abcabc" I need to search 'a' in var1 and want to replace with 'x' like 'xbcxbc'. Is it possible? Can you provide me an example? Malay (3 Replies)
Discussion started by: malaymaru
3 Replies

4. UNIX for Dummies Questions & Answers

String Search & Replace

Hey, I want to have a C program which, for an existing file supplied by the command line argument (E.g. File1.txt) replaces all the occurrences of the words: "We” or “we” by “I” “a” by “the” “A” by “The”. Then print the replaced file. All other characters of the file are to be left... (1 Reply)
Discussion started by: IwishIknewC
1 Replies

5. Shell Programming and Scripting

Need help with search & replace

I have a file that has some accent characters in it when viewed in some text editors, but when viewed in vi they come in as ~R and ~U. I need to make a script to remove these characters from the file, but have been unsuccessful. I am not sure how sed or awk, or something similar is viewing them,... (8 Replies)
Discussion started by: tcovert
8 Replies

6. UNIX for Dummies Questions & Answers

Search & Replace

Hi , I ahve a text file which has several instances of the text such as run_time: 09:30 I need to add double quotes before and after the time value i.e: run_time: "09:30" Any suggestions on how to go about the same (4 Replies)
Discussion started by: jobbyjoseph
4 Replies

7. Shell Programming and Scripting

search & replace pattern

Hi, My problem is that I have to search a changing pattern and replace it with the wild card char "*" i/p: 99_*_YYYYMMDD_SRC.txt.tar.gz o/p: 99_*_*_SRC.txt.tar.gz The problem is that YYYYMMDD pattern is not static. It could be YYYYMMDDHHMI or could be YYYYMMDDHHMISS. Can... (10 Replies)
Discussion started by: dips_ag
10 Replies

8. Shell Programming and Scripting

Search & Replace

Hi all Please can you help me with a script to check several files for the following string: encoding=""and replace it with: encoding="UTF-8"I did the following, : #!/bin/sh string1="encoding=""" string2="encoding="UTF-8" sed 's/'"$string1"'/'"$string2"'/g'but does not work. Please can... (18 Replies)
Discussion started by: fretagi
18 Replies

9. Shell Programming and Scripting

Mathematical Operations on Column

Hi All, I want to perform a mathematical operation on column. Can anyone please help? Here is the sample of operation to be performed: 123 996 100 123 996 200 123 996 200 2015-09-21 123 996 100 123 996 200 123 996 100 What I want is to multiple all values of column # 3 by 100 and... (3 Replies)
Discussion started by: Zaib
3 Replies

10. Shell Programming and Scripting

Search & Replace

Hi Gurus, I have two files. I want to read sessoin_name from the file1 and replace $Param4 & $Param5 in file2 with connection_name in specified in file1. The file1 will have data in following format File 1 session_name,connection_name s_abcd,Listener_2 s_def,Listener_1 source file... (7 Replies)
Discussion started by: r_t_1601
7 Replies
PACEMAKER(8)						  System Administration Utilities					      PACEMAKER(8)

NAME
Pacemaker - Part of the Pacemaker cluster resource manager SYNOPSIS
cibadmin command [options] [data] DESCRIPTION
cibadmin - Provides direct access to the cluster configuration. Allows the configuration, or sections of it, to be queried, modified, replaced and deleted. Where necessary, XML data will be obtained using the -X, -x, or -p options OPTIONS
-?, --help This text -$, --version Version information -V, --verbose Increase debug output Commands: -u, --upgrade Upgrade the configuration to the latest syntax -Q, --query Query the contents of the CIB -E, --erase Erase the contents of the whole CIB -B, --bump Increase the CIB's epoch value by 1 -C, --create Create an object in the CIB. Will fail if the object already exists. -M, --modify Find the object somewhere in the CIB's XML tree and update it. Fails if the object does not exist unless -c is specified -P, --patch Supply an update in the form of an xml diff (See also: crm_diff) -R, --replace Recursivly replace an object in the CIB -D, --delete Delete the first object matching the supplied criteria, Eg. <op id="rsc1_op1" name="monitor"/> The tagname and all attributes must match in order for the element to be deleted -d, --delete-all When used with --xpath, remove all matching objects in the configuration instead of just the first one -5, --md5-sum Calculate the on-disk CIB digest -6, --md5-sum-versioned Calculate an on-the-wire versioned CIB digest -S, --sync (Advanced) Force a refresh of the CIB to all nodes -a, --empty Output an empty CIB Additional options: -f, --force -t, --timeout=value Time (in seconds) to wait before declaring the operation failed -s, --sync-call Wait for call to complete before returning -l, --local Command takes effect locally. Should only be used for queries -c, --allow-create (Advanced) Allow the target of a -M operation to be created if they do not exist -n, --no-children (Advanced) When querying an object, do not return include its children in the result Data: -X, --xml-text=value Retrieve XML from the supplied string -x, --xml-file=value Retrieve XML from the named file -p, --xml-pipe Retrieve XML from stdin -A, --xpath=value A valid XPath to use instead of -o -o, --scope=value Limit the scope of the operation to a specific section of the CIB. Valid values are: nodes, resources, constraints, crm_config, rsc_defaults, op_defaults, status -N, --node=value (Advanced) Send command to the specified host EXAMPLES
Query the configuration from the local node: # cibadmin --query --local Query the just the cluster options configuration: # cibadmin --query --scope crm_config Query all 'target-role' settings: # cibadmin --query --xpath "//nvpair[@name='target-role']" Remove all 'is-managed' settings: # cibadmin --delete-all --xpath "//nvpair[@name='is-managed']" Remove the resource named 'old': # cibadmin --delete --xml-text '<primitive id="old"/>' Remove all resources from the configuration: # cibadmin --replace --scope resources --xml-text '<resources/>' Replace the complete configuration with the contents of $HOME/pacemaker.xml: # cibadmin --replace --xml-file $HOME/pacemaker.xml Replace the constraints section of the configuration with the contents of $HOME/constraints.xml: # cibadmin --replace --scope constraints --xml-file $HOME/constraints.xml Increase the configuration version to prevent old configurations from being loaded accidentally: # cibadmin --modify --xml-text '<cib admin_epoch="admin_epoch++"/>' Edit the configuration with your favorite $EDITOR: # cibadmin --query > $HOME/local.xml # $EDITOR $HOME/local.xml # cibadmin --replace --xml-file $HOME/local.xml SEE ALSO: CRM shell, crm(8), crm_shadow(8) AUTHOR
Written by Andrew Beekhof REPORTING BUGS
Report bugs to pacemaker@oss.clusterlabs.org Pacemaker 1.1.7 April 2012 PACEMAKER(8)
All times are GMT -4. The time now is 06:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy