Sponsored Content
Full Discussion: Can't understand the script
Top Forums Shell Programming and Scripting Can't understand the script Post 302380325 by shahdharmit on Monday 14th of December 2009 09:59:07 PM
Old 12-14-2009
Can't understand the script

I am relatively new to Shell Scripting. I can't understand the following two scripts. Can someone please spare a minute to explain?

1) content s of file a are

(021) 654-1234
Code:
sed 's/(//g;s/)//g;s/ /-/g' a
021-654-1234

2)
Code:
cut -d: -f1,3,7 /etc/passwd |sort -t: +1n

gives error
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help wanted to understand MQ script

hi , i am writing a script to copy the MQ messages from onw queue to another. The following i got from one site, but i di not understand , can anyone explain. /root/scripts/sap/q -m$Q_MANAGER -i$Q_NAME_SRC_1 -F/logs/mq/MQ_COPYdump_$Q_NAME_SRC_1.$$ /root/scripts/sap/q -m$Q_MANAGER... (0 Replies)
Discussion started by: Satyak
0 Replies

2. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

3. Shell Programming and Scripting

Need to understand the script pls help

Can u please explain what it is doing #!/bin/sh fullyear=`/home/local/bin/datemmdd 1`"."`date +%Y` uehist=/u05/home/celldba/utility/ue/prod/history echo $fullyear cd $uehist ls -ltr pwroutages.master.$fullyear* | awk '{print $9}' > /u01/home/celldba/tmp/pwroutages_master_all_tmp while... (2 Replies)
Discussion started by: raopatwari
2 Replies

4. Shell Programming and Scripting

Need help to understand ksh script

Hi All, I have a ksh script & would like to understand mening of below lines in script, Starting lines of script is as below, #!/bin/ksh #%W% %I% %D% %T% ---- ??? #%W%G --- ??? num_ctrl_files=0 OS=`uname` if then //g' | egrep -v '(.sh:|.ksh:)' | sed 's/^.*://g' | sed 's/^M//g' |... (6 Replies)
Discussion started by: gr8_usk
6 Replies

5. Shell Programming and Scripting

Understand script formte

Hi i have one script and i am running it but not getting current output so i want to understand how to input in the script. when i do help then i am getting below massage thanks got it (1 Reply)
Discussion started by: asavaliya
1 Replies

6. Shell Programming and Scripting

Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words. { part = word2key($1) data = $1 } function word2key(word, a, i, x, result) { x = split(word, a, "") asort(a) ... (1 Reply)
Discussion started by: jose2802
1 Replies

7. Shell Programming and Scripting

Can't understand script output

New to korn shel1 and having an issue. The following is suppose to read the parameter values from files in a source directory and then pass them on to a log file in a different directory, The ArchiveTracker scripts is suppose to call the parameterreader script to exact the parameter values and... (3 Replies)
Discussion started by: bayouprophet
3 Replies

8. Shell Programming and Scripting

Need help to understand the below shell script

Please help me to understand the below 3 lines of code.execute shell in jenkins 1)APP_IP=$( docker inspect --format '{{ .NetworkSettings.Networks.'"$DOCKER_NETWORK_NAME"'.IPAddress }}' ${PROJECT_NAME_KEY}"-CI" ) 2)HOST_WORKSPACE=$(echo ${WORKSPACE} | sed... (1 Reply)
Discussion started by: naresh85
1 Replies

9. UNIX for Beginners Questions & Answers

Help me understand this script

#!/bin/awk -f BEGIN {i=1;file="modified.txt"} { if ($0 !~ /^DS:/) {print $0 >> file} else { if ($0 ~ /^DS:/) {print "DS: ",i >> file;if (i==8) {i=1} else {i++}}; } } END {gzip file} Can someone explain to me how this above script works, I got it from a friend but not able... (3 Replies)
Discussion started by: Kamesh G
3 Replies
String::Errf(3pm)					User Contributed Perl Documentation					 String::Errf(3pm)

NAME
String::Errf - a simple sprintf-like dialect VERSION
version 0.006 SYNOPSIS
use String::Errf qw(errf); print errf "This process was started at %{start}t with %{args;argument}n. ", { start => $^T, args => 0 + @ARGV }; ...might print something like: This process was started at 2010-10-17 14:05:29 with 0 arguments. DESCRIPTION
String::Errf provides "errf", a simple string formatter that works something like "sprintf". It is implemented using String::Formatter and Sub::Exporter. Their documentation may be useful in understanding or extending String::Errf. DIFFERENCES FROM SPRINTF
The data passed to "errf" should be organized in a single hashref, not a list. Formatting codes require named parameters, and the available codes are different. See "FORMATTING CODES" below. As with most String::Formatter formatters, "%" is not a format code. If you want a literal "%", do not put anything between the two percent signs, just write "%%". FORMATTING CODES "errf" formatting codes require a set of arguments between the "%" and the formatting code letter. These arguments are placed in curly braces and separated by semicolons. The first argument is the name of the data to look for in the format data. For example, this is a valid use of "errf": errf "The current time in %{tz}s is %{now;local}t.", { tz => $ENV{TZ}, now => time, }; The second argument, if present, may be a compact form for multiple named arguments. The rest of the arguments will be named values in the form "name=value". The examples below should help clarify how arguments are passed. When an argument appears in both a compact and named form, the named form trumps the compact form. The specific codes and their arguments are: s for string The "s" format code is for any string, and takes no arguments. It just includes the named item from the input data. errf "%{name}s", { name => 'John Smith' }; # returns "John Smith" Remember, "errf" does not have any of the left- or right-padding formatting that "sprintf" provides. It is not meant for building tables, only strings. i for integer The "i" format code is used for integers. It takes one optional argument, "prefix", which defaults to the empty string. "prefix" may be given as the compact argument, standing alone. "prefix" is used to prefix non-negative integers. It may only be a plus sign. errf "%{x}i", { x => 10 }; # returns "10" errf "%{x;+}i", { x => 10 }; # returns "+10" errf "%{x;prefix=+}i", { x => 10 }; # returns "+10" The rounding behavior for non-integer values is not currently specified. f for float (or fractional) The "f" format code is for numbers with sub-integer precision. It works just like "i", but adds a "precision" argument which specifies how many decimal places of precision to display. The compact argument may be just the prefix or the prefix followed by a period followed by the precision. errf "%{x}f", { x => 10.1234 }; # returns "10"; errf "%{x;+}f", { x => 10.1234 }; # returns "+10"; errf "%{x;.2}f", { x => 10.1234 }; # returns "10.12"; errf "%{x;+.2}f", { x => 10.1234 }; # returns "+10.12"; errf "%{x;precision=.2}f", { x => 10.1234 }; # returns "10.12"; errf "%{x;prefix=+;precision=.2}f", { x => 10.1234 }; # returns "+10.12"; t for time The "t" format code is used to format timestamps provided in epoch seconds. It can be given two arguments: "type" and "tz". "type" can be either date, time, or datetime, and indicates what part of the timestamp should be displayed. The default is datetime. "tz" requests that the timestamp be displayed in either UTC or the local time zone. The default is local. The compact form is just "type" alone. # Assuming our local time zone is America/New_York... errf "%{x}t", { x => 1280530906 }; # "2010-07-30 19:01:46" errf "%{x;type=date}t", { x => 1280530906 }; # "2010-07-30" errf "%{x;type=time}t", { x => 1280530906 }; # "19:01:46" errf "%{x;type=datetime}t", { x => 1280530906 }; # "2010-07-30 19:01:46" errf "%{x;tz=UTC}t", { x => 1280530906 }; # "2010-07-30 23:01:46 UTC" errf "%{x;tz=UTC;type=date}t", { x => 1280530906 }; # "2010-07-30 UTC" errf "%{x;tz=UTC;type=time}t", { x => 1280530906 }; # "23:01:46 UTC" errf "%{x;tz=UTC;type=datetime}t", { x => 1280530906 }; # "2010-07-30 23:01:46 UTC" n and N for numbered The "n" and "N" format codes are for picking words based on number. It takes two of its own arguments, "singular" and "plural", as well as "prefix" and "precision" which may be used for formatting the number itself. If the value being formatted is 1, the singular word is used. Otherwise, the plural form is used. errf "%{x;singular=dog;plural=dogs}n", { x => 0 }; # 0 dogs errf "%{x;singular=dog;plural=dogs}n", { x => 1 }; # 1 dog errf "%{x;singular=dog;plural=dogs}n", { x => 2 }; # 2 dogs errf "%{x;singular=dog;plural=dogs}n", { x => 1.4 }; # 1.4 dogs errf "%{x;singular=dog;plural=dogs;precision=1}n", { x => 1.4 }; # 1.4 dogs errf "%{x;singular=dog;plural=dogs;precision=0}n", { x => 1.4 }; # 1 dog If "N" is used instead of "n", the number will not be included, only the chosen word. errf "%{x;singular=is;plural=are}N", { x => 0 }; # are errf "%{x;singular=is;plural=are}N", { x => 1 }; # is errf "%{x;singular=is;plural=are}N", { x => 2 }; # are errf "%{x;singular=is;plural=are}N", { x => 1.4 }; # 1.4 are errf "%{x;singular=is;plural=are;precision=1}N", { x => 1.4 }; # 1.4 are errf "%{x;singular=is;plural=are;precision=0}N", { x => 1.4 }; # 1 is The compact form may take any of the following forms: word - equivalent to singular=word word+suffix - equivalent to singular=word;plural=wordsuffix word1/word2 - equivalent to singular=word;plural=word2 If no singular form is given, an exception is thrown. If no plural form is given, one will be generated according to some basic rules of English noun orthography. AUTHOR
Ricardo Signes <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.3 2010-10-29 String::Errf(3pm)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy