07-10-2019
NF number of fields
$1 first field
$2 field 2
$NF last field
$(NF-1) second last field
sub() substitute
gsub() globally substitute, apply multiple subsequent substitutions
sub("/", "-", $NF) substitute a / with a - in the last field
gsub("/", "-", $NF) globally substitute a / with a - in the last field
This User Gave Thanks to MadeInGermany For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello All
I have file which contain sample data like below -
test.txt
----------------------------------------------
jambesh aaa india
trxxx
sdasd
mentor
asss
light
train
bbblah
---------------------------------------------
I want to write a regX which would print only those... (4 Replies)
Discussion started by: jambesh
4 Replies
2. Shell Programming and Scripting
I've got a file (numbers.txt) filled with numbers and I want to replace each one of those numbers with a new random number between 0 and 9. This is my script so far:
#!/bin/bash
rand=$(($RANDOM % 9))
sed -i s//$rand/g numbers.txtThe problem that I have is that it replaces each number with just... (2 Replies)
Discussion started by: hellocatfood
2 Replies
3. Shell Programming and Scripting
Hi,
I am looking for any script which can do the following.
have to read a pattern from fileA and copy it to fileB.
fileA:
...
...
Header
...
...
..p1
...
...
fileB:
....
....
Header (3 Replies)
Discussion started by: anilvk
3 Replies
4. Shell Programming and Scripting
i need to replace the any special characters with escape characters like below.
test!=123-> test\!\=123
!@#$%^&*()-= to be replaced by
\!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies
5. Shell Programming and Scripting
I have a file with 22 lines. Each line has only 5 different chars, no white space, and each line is 3,278,824 in length. The 5 chars is "-", "A", "B", "C", "D".
Below is an example of the first 25 chars of the first four lines of the file.
-----ABCDA--CD-BBBBB----D
--A--ABCD--DCD-BBBBC-----... (12 Replies)
Discussion started by: cwzkevin
12 Replies
6. UNIX for Dummies Questions & Answers
I have input file like this
update tablename set column1='ABC',column2='BBC' where columnx=1 and columny=100 and columnz='10000001'
update tablename set column1='ABC',column2='BBC',column3='CBC' where columnx=1 and columny=100 and columnz='10000002'
update tablename set column1='ABC' where... (1 Reply)
Discussion started by: nsuresh316
1 Replies
7. Shell Programming and Scripting
Hi,
I want to extract the next 7 characters after I encounter the first ( in the code
eg
abc123=(xvn1342)
xyz678123=(ret8901)
I want to extract xvn1342,ret8901.
Please advise how to achieve this with awk, if possible? (9 Replies)
Discussion started by: sidnow
9 Replies
8. Shell Programming and Scripting
Im using the command below , but thats not the output that i want. it only prints the odd and even numbers.
awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}'
Im hoping for something like this
file1:
Text hi this is just a test
text1 text2 text3 text4 text5 text6
Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies
9. Shell Programming and Scripting
How to match a shell variable that contains parenthesis (and other special characters like "!")
file.txt contains:
Charles Dickens
Matthew Lewis (writer)
name="Matthew Lewis (writer)";
awk -v na="$name" ' $0 ~ na' file.txt
Ideally this would match $name in file.txt (in this... (3 Replies)
Discussion started by: Mid Ocean
3 Replies
10. UNIX for Beginners Questions & Answers
I would like to insert n number of characters at the beginning of each line that starts with a given character. If possible, I would be most appreciative for a sed or awk solution.
Given the data below, I would like to be able to insert either 125 spaces or 125 "-" at the beginning of every line... (6 Replies)
Discussion started by: jvoot
6 Replies
LEARN ABOUT PHP
odbc_result
ODBC_RESULT(3) 1 ODBC_RESULT(3)
odbc_result - Get result data
SYNOPSIS
mixed odbc_result (resource $result_id, mixed $field)
DESCRIPTION
Get result data
PARAMETERS
o $result_id
- The ODBC resource.
o $field
- The field name being retrieved. It can either be an integer containing the column number of the field you want; or it can be a
string containing the name of the field.
RETURN VALUES
Returns the string contents of the field, FALSE on error, NULL for NULL data, or TRUE for binary data.
EXAMPLES
The first call to odbc_result(3) returns the value of the third field in the current record of the query result. The second function call
to odbc_result(3) returns the value of the field whose field name is "val" in the current record of the query result. An error occurs if a
column number parameter for a field is less than one or exceeds the number of columns (or fields) in the current record. Similarly, an
error occurs if a field with a name that is not one of the fieldnames of the table(s) that is(are) being queried.
Example #1
odbc_result(3) examples
<?php
$item_3 = odbc_result($Query_ID, 3);
$item_val = odbc_result($Query_ID, "val");
?>
NOTES
Field indices start from 1. Regarding the way binary or long column data is returned refer to odbc_binmode(3) and odbc_longreadlen(3).
PHP Documentation Group ODBC_RESULT(3)