Sponsored Content
Full Discussion: awk to remove last two -*-*
Top Forums Shell Programming and Scripting awk to remove last two -*-* Post 302751967 by RudiC on Saturday 5th of January 2013 05:51:52 AM
Old 01-05-2013
I had wanted to offer sth like
Code:
$ awk -F '-' '{for (i=1;i<NF-2;i++) printf "%s-", $i; printf "%s\n", $(i) }' file

but scutinizer's proposals beat them all!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove ^Z (eof) using sub in awk

I am looking for the substitution expression to remove the eof ^Z character at the end of a file in UNIX. Can anyone help? Thank you ! (2 Replies)
Discussion started by: placroix1
2 Replies

2. Shell Programming and Scripting

Remove prefix using awk

Remove prefix using awk File: nawk -F"|" '{if ($1 ~ /^xyz./) print; else { gsub(.*\..*, \..*, $1) ;print }}' file Error: ouput required: (5 Replies)
Discussion started by: pinnacle
5 Replies

3. Shell Programming and Scripting

a SED/AWK way to remove everything except...

Hi all, I have a logfile which has lines as following: DOMAIN\username,Deposit,DOMAIN\ServiceAccountName,25/03/2010,00:10,\\SERVER,,,,/Ts=4BAA9BD6,,,10.00,10.03 It's a log of a pcounter print charge system. I need to only have the first part (domain\username) and the second last... (4 Replies)
Discussion started by: necron
4 Replies

4. Shell Programming and Scripting

AWK remove string in between ()

Hi Everyone, 1.txt test here (888_f)a/fff (eeee) test2 (q)--(qq) the output is test here a/fff test2 -- means remove the characters in between (), and () itself. Please advice. Thanks (3 Replies)
Discussion started by: jimmy_y
3 Replies

5. Shell Programming and Scripting

can I remove the first char using AWK?

Hi everyone, suppose that I have the following line: #test your knowledge can I use AWK to print the word "test" only? without the #? what should I change to this: awk '{print $1}' thanks in advance guys (2 Replies)
Discussion started by: Abdulelah
2 Replies

6. Shell Programming and Scripting

Awk: Remove Duplicates

I have the following code for removing duplicate records based on fields in inputfile file & moves the duplicate records in duplicates file(1st Awk) & in 2nd awk i fetch the non duplicate entries in inputfile to tmp file and use move to update the original file. Requirement: Can both the awk... (4 Replies)
Discussion started by: siramitsharma
4 Replies

7. Shell Programming and Scripting

awk remove first duplicates

Hi All, I have searched many threads for possible close solution. But I was unable to get simlar scenario. I would like to print all duplicate based on 3rd column except the first occurance. Also would like to print if it is single entry(non-duplicate). i/P file 12 NIL ABD LON 11 NIL ABC... (6 Replies)
Discussion started by: sybadm
6 Replies

8. Shell Programming and Scripting

awk remove line

I would like to remove lines with certain pattern but only Estimate: and Realised: in USD and Date: shall be output. The order of the currency are mixed. Output I failed on awk with sub, gensub and was not able to remove the multiple entry on the * Date: (2 Replies)
Discussion started by: sdf
2 Replies

9. Shell Programming and Scripting

How can I remove first column with awk?

cat input.txt a x b y c z Expected output x y z (11 Replies)
Discussion started by: cola
11 Replies

10. UNIX for Beginners Questions & Answers

Remove character \r and \n in awk

Hi Everybody: I need your help, please... I have this file *.txt 0000 | 16010201 22000000 67892000 00000000 00000000 00000100 72246681 28E08236 | ~~~~"~~~g~ ~~~~~~~~~~~~~r$f~(~~6 | 0020 | 10476173 90010100 10000000 00000001 05000226 17163011 12442212 48140484 |... (2 Replies)
Discussion started by: solaris21
2 Replies
PDOSTATEMENT.EXECUTE(3) 						 1						   PDOSTATEMENT.EXECUTE(3)

PDOStatement::execute - Executes a prepared statement

SYNOPSIS
public bool PDOStatement::execute ([array $input_parameters]) DESCRIPTION
Execute the prepared statement. If the prepared statement included parameter markers, you must either: ocall PDOStatement.bindParam(3) to bind PHP variables to the parameter markers: bound variables pass their value as input and receive the output value, if any, of their associated parameter markers oor pass an array of input-only parameter values PARAMETERS
o $input_parameters - An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as PDO::PARAM_STR. You cannot bind multiple values to a single parameter; for example, you cannot bind two values to a single named parameter in an IN() clause. You cannot bind more values than specified; if more keys exist in $input_parameters than in the SQL specified in the PDO::prepare, then the statement will fail and an error is emitted. RETURN VALUES
Returns TRUE on success or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.2.0 | | | | | | | The keys from $input_parameters must match the | | | ones declared in the SQL. Before PHP 5.2.0 this | | | was silently ignored. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 Execute a prepared statement with bound variables <?php /* Execute a prepared statement by binding PHP variables */ $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour'); $sth->bindParam(':calories', $calories, PDO::PARAM_INT); $sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12); $sth->execute(); ?> Example #2 Execute a prepared statement with an array of insert values (named parameters) <?php /* Execute a prepared statement by passing an array of insert values */ $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour'); $sth->execute(array(':calories' => $calories, ':colour' => $colour)); ?> Example #3 Execute a prepared statement with an array of insert values (placeholders) <?php /* Execute a prepared statement by passing an array of insert values */ $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ? AND colour = ?'); $sth->execute(array($calories, $colour)); ?> Example #4 Execute a prepared statement with question mark placeholders <?php /* Execute a prepared statement by binding PHP variables */ $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ? AND colour = ?'); $sth->bindParam(1, $calories, PDO::PARAM_INT); $sth->bindParam(2, $colour, PDO::PARAM_STR, 12); $sth->execute(); ?> Example #5 Execute a prepared statement using array for IN clause <?php /* Execute a prepared statement using an array of values for an IN clause */ $params = array(1, 21, 63, 171); /* Create a string for the parameter placeholders filled to the number of params */ $place_holders = implode(',', array_fill(0, count($params), '?')); /* This prepares the statement with enough unnamed placeholders for every value in our $params array. The values of the $params array are then bound to the placeholders in the prepared statement when the statement is executed. This is not the same thing as using PDOStatement::bindParam() since this requires a reference to the variable. PDOStatement::execute() only binds by value instead. */ $sth = $dbh->prepare("SELECT id, name FROM contacts WHERE id IN ($place_holders)"); $sth->execute($params); ?> NOTES
Note Some drivers require to close cursor before executing next statement. SEE ALSO
PDO.prepare(3), PDOStatement.bindParam(3), PDOStatement.fetch(3), PDOStatement.fetchAll(3), PDOStatement.fetchColumn(3). PHP Documentation Group PDOSTATEMENT.EXECUTE(3)
All times are GMT -4. The time now is 08:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy