Sponsored Content
Top Forums Shell Programming and Scripting How to escape "*" using awk inside script? Post 303046046 by vgersh99 on Wednesday 22nd of April 2020 10:41:08 AM
Old 04-22-2020
Quote:
Originally Posted by rogerben
actually the column 2 value is not constant and it will vary based on different ids, so cant check with that particular id . Need to get the value if i fetched the userid and corresponding password
ok, still no need for grep.
Code:
val2search='jij'

a="$(awk -v v2s="${val2search}" '$2==v2s {print $3}' testfile)"
echo "$a"

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Solaris

Solaris escape my script from "-" to "/226"

Hello everyone. I beg your guys pardon please. I try to ls -al in many path/directories. So, I put the code in text file which look like below; ls -al / ls -al /etc ls -al /etc/default ... however, when I paste it to Solaris over SecureCRT, it seems the code was escaped from "-" to... (0 Replies)
Discussion started by: Smith
0 Replies

3. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

4. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

5. Shell Programming and Scripting

Awk to Search and Replace inside the pipe "|"

Hi, Anyone can help me on how to replace the qoutes inside the pipe | in my Text File like belows; "AAAA"|"Test "1-A""|"Test AAAA"|"This is A" "BBBB"|"Test "1-B""|"Test BBBB"|"This is B" "CCCC"|"My Test C"|"Test "CCCC""|"This is C" The output I need like belows; "AAAA"|"Test 1-A"|"Test... (12 Replies)
Discussion started by: fspalero
12 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

8. Shell Programming and Scripting

Passing username and password to a script running inside "expect" script

Hi I'm trying to run a script " abc.sh" which triggers "use.sh" . abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script. Please find below the scripts: #abc.sh #!/usr/bin/expect -f exec /root/use.sh expect "*name*" send... (1 Reply)
Discussion started by: baddykam
1 Replies

9. Shell Programming and Scripting

How to increment date using "for loop" in format MMDDYY inside the shell script?

Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50) (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
DB2_GET_OPTION(3)							 1							 DB2_GET_OPTION(3)

db2_get_option - Retrieves an option value for a statement resource or a connection resource

SYNOPSIS
string db2_get_option (resource $resource, string $option) DESCRIPTION
Retrieves the value of a specified option value for a statement resource or a connection resource. PARAMETERS
o $resource - A valid statement resource as returned from db2_prepare(3) or a valid connection resource as returned from db2_connect(3) or db2_pconnect(3). o $option - A valid statement or connection options. The following new options are available as of ibm_db2 version 1.6.0. They provide use- ful tracking information that can be set during execution with db2_get_option(3). Note Prior versions of ibm_db2 do not support these new options. When the value in each option is being set, some servers might not handle the entire length provided and might truncate the value. To ensure that the data specified in each option is converted correctly when transmitted to a host system, use only the characters A through Z, 0 through 9, and the underscore (_) or period (.). o $userid - SQL_ATTR_INFO_USERID - A pointer to a null-terminated character string used to identify the client user ID sent to the host database server when using DB2 Connect. Note DB2 for z/OS and OS/390 servers support up to a length of 16 characters. This user-id is not to be confused with the authentication user-id, it is for identification purposes only and is not used for any authorization. o $acctstr - SQL_ATTR_INFO_ACCTSTR - A pointer to a null-terminated character string used to identify the client accounting string sent to the host database server when using DB2 Connect. Note DB2 for z/OS and OS/390 servers support up to a length of 200 characters. o $applname - SQL_ATTR_INFO_APPLNAME - A pointer to a null-terminated character string used to identify the client application name sent to the host database server when using DB2 Connect. Note DB2 for z/OS and OS/390 servers support up to a length of 32 characters. o $wrkstnname - SQL_ATTR_INFO_WRKSTNNAME - A pointer to a null-terminated character string used to identify the client workstation name sent to the host database server when using DB2 Connect. Note DB2 for z/OS and OS/390 servers support up to a length of 18 characters. The following table specifies which options are compatible with the available resource types: Resource-Parameter Matrix +-----------+--------------------------+---+---+---+ | Key | | | | | | | | | | | | | Value | | | | | | | | | | | | Resource Type | | | | | | | | | | +-----------+--------------------------+---+---+---+ |Connection | | | | | | | | | | | | | Statement | | | | | | | | | | | | Result Set | | | | | | | | | | | userid | | | | | | | | | | | | | | | | | | | SQL_ATTR_INFO_USERID | | | | | | | | | | | | X | | | | | | | | | | | | X | | | | | | | | | | | | - | | | | | | | | | | | acctstr | | | | | | | | | | | | | | | | | | | SQL_ATTR_INFO_ACCTSTR | | | | | | | | | | | | X | | | | | | | | | | | | X | | | | | | | | | | | | - | | | | | | | | | | | applname | | | | | | | | | | | | | | | | | | | SQL_ATTR_INFO_APPLNAME | | | | | | | | | | | | X | | | | | | | | | | | | X | | | | | | | | | | | | - | | | | | | | | | | |wrkstnname | | | | | | | | | | | | | | | | | | | SQL_ATTR_INFO_WRKSTNNAME | | | | | | | | | | | | X | | | | | | | | | | | | X | | | | | | | | | | | | - | | | | | | | | | | +-----------+--------------------------+---+---+---+ RETURN VALUES
Returns the current setting of the connection attribute provided on success or FALSE on failure. EXAMPLES
Example #1 Setting and retrieving parameters through a connection resource <?php /* Database Connection Parameters */ $database = 'SAMPLE'; $user = 'db2inst1'; $password = 'ibmdb2'; /* Obtain Connection Resource */ $conn = db2_connect($database, $user, $password); echo "Client attributes passed through connection string: "; /* Create the associative options array with valid key-value pairs */ /* Assign the attributes through connection string */ /* Access the options specified */ $options1 = array('userid' => 'db2inst1'); $conn1 = db2_connect($database, $user, $password, $options1); $val = db2_get_option($conn1, 'userid'); echo $val . " "; $options2 = array('acctstr' => 'account'); $conn2 = db2_connect($database, $user, $password, $options2); $val = db2_get_option($conn2, 'acctstr'); echo $val . " "; $options3 = array('applname' => 'myapp'); $conn3 = db2_connect($database, $user, $password, $options3); $val = db2_get_option($conn3, 'applname'); echo $val . " "; $options4 = array('wrkstnname' => 'workstation'); $conn4 = db2_connect($database, $user, $password, $options4); $val = db2_get_option($conn4, 'wrkstnname'); echo $val . " "; echo "Client attributes passed post-connection: "; /* Create the associative options array with valid key-value pairs */ /* Assign the attributes after a connection is made */ /* Access the options specified */ $options5 = array('userid' => 'db2inst1'); $conn5 = db2_connect($database, $user, $password); $rc = db2_set_option($conn5, $options5, 1); $val = db2_get_option($conn5, 'userid'); echo $val . " "; $options6 = array('acctstr' => 'account'); $conn6 = db2_connect($database, $user, $password); $rc = db2_set_option($conn6, $options6, 1); $val = db2_get_option($conn6, 'acctstr'); echo $val . " "; $options7 = array('applname' => 'myapp'); $conn7 = db2_connect($database, $user, $password); $rc = db2_set_option($conn7, $options7, 1); $val = db2_get_option($conn7, 'applname'); echo $val . " "; $options8 = array('wrkstnname' => 'workstation'); $conn8 = db2_connect($database, $user, $password); $rc = db2_set_option($conn8, $options8, 1); $val = db2_get_option($conn8, 'wrkstnname'); echo $val . " "; ?> The above example will output: Client attributes passed through connection string: db2inst1 account myapp workstation Client attributes passed post-connection: db2inst1 account myapp workstation SEE ALSO
db2_connect(3), db2_cursor_type(3), db2_exec(3), db2_set_option(3), db2_pconnect(3), db2_prepare(3). PHP Documentation Group DB2_GET_OPTION(3)
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy