Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Displaying Number with printf Post 302166300 by ynixon on Monday 11th of February 2008 03:00:03 PM
Old 02-11-2008
Quote:
Originally Posted by quintet
try this

echo 1234 | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'
I found a nicer option (still in sed Smilie )
echo 1234 | sed ':a;s/\([[:digit:]]\)\([[:digit:]]\{3\}\b\)/\1,\2/g;ta'
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printf returning unknown number

Hi, Can anybody tell me why this function returns 49? printf "%d\n" \'10 I don't understand what the \ and ' are there for? thanks!!! (1 Reply)
Discussion started by: m0nk3y
1 Replies

2. Programming

printf

What is the output of the following program considering an x86 based parameter passing sequence where stack grows towards lower memory addresses and that arguments are evaluated from right to left: int i=10; int f1() { static int i = 15; printf("f1:%d ", i); return i--; } main() {... (2 Replies)
Discussion started by: arunviswanath
2 Replies

3. Shell Programming and Scripting

Displaying Number with printf

I am trying to display a number with commas printf "%d\n" 323232 printf "%d\n" 1234567 I want the output to be: 323,232 1,234,567 I tried to change %d to other formats and could find the solution. any idea? (7 Replies)
Discussion started by: ynixon
7 Replies

4. Shell Programming and Scripting

Displaying number of lines from file

Hi, I am using below command to display the number of line, but its returning no of lines along with file name. But i want only no of line in the variable p. Please help me on this? p=`wc -l "text file"` echo "$p" (6 Replies)
Discussion started by: shivanete
6 Replies

5. Shell Programming and Scripting

AWK: formating number without printf

Hello, I wrote a script that does lot of things, and I would like to change the format of a number but without printing it now (so I don't want to use printf as it will print the value immediately). Schematically here is what I have: awk 'BEGIN{number=0.01234567} $1==$2{$3=number}... (5 Replies)
Discussion started by: jolecanard
5 Replies

6. Shell Programming and Scripting

Displaying lines of a file which have the highest number?

Hello Wondering if anybody may be able to advise on how I can filter the contents of the following file: <object_name>-<version> <Instance> GM_GUI_code.fmb-4 1 GM_GUI_code.fmb-5 1 GM_GUI_code.fmx-4 ... (7 Replies)
Discussion started by: Glyn_Mo
7 Replies

7. Shell Programming and Scripting

Displaying a number in binary using perl

printf FH2" 3'b%b : begin\n",$i; where i is an integer in the loop is displaying 3'b1 : begin expected output was 3'b001 : begin (1 Reply)
Discussion started by: dll_fpga
1 Replies

8. Shell Programming and Scripting

Not able to sort two fields and printf not displaying the correct values

Not able to sorting two fileds resolved printf issue 01-1000/9|JAN 01-0000/6|MAN 01-1010/2|JAN 01-1010/2|JAN 01-1010/2|JAN 01-1000/9|JAN 01-1000/9|JAN 01-1000/9|SAA 01-1000/9|SAA 01-0000/6|SAN 01-0000/6|SAN 1.sort -t'|' -k1,1n -k2,2 file (3 Replies)
Discussion started by: kalia4u
3 Replies

9. Shell Programming and Scripting

Adding user name to file, and then displaying new line number

Hi all - I'm completely stumped by a script I'm working on... The short version is I have a file called 'lookup' and in it are hundreds of names (first and last). I have a script that basically allows the user to enter a name, and what I need to have happen is something like this: Record... (8 Replies)
Discussion started by: sabster
8 Replies

10. UNIX for Beginners Questions & Answers

Printf() not displaying as it should.

Hi, I have some code. Everything works as it should, but, when I call view_all_contacts() to print the data, each line doesn't line up as it should. I get tab keys between each line. The problem code is this: printf("\n\eHere is the rest of the code: void add_contact();... (5 Replies)
Discussion started by: ignatius
5 Replies
OCI_ERROR(3)															      OCI_ERROR(3)

oci_error - Returns the last error found

SYNOPSIS
array oci_error ([resource $resource]) DESCRIPTION
Returns the last error found. The function should be called immediately after an error occurs. Errors are cleared by a successful statement. PARAMETERS
o $resource - For most errors, $resource is the resource handle that was passed to the failing function call. For connection errors with oci_connect(3), oci_new_connect(3) or oci_pconnect(3) do not pass $resource. RETURN VALUES
If no error is found, oci_error(3) returns FALSE. Otherwise, oci_error(3) returns the error information as an associative array. oci_error(3) Array Description +----------+--------------------------------------+---+ |Array key | | | | | | | | | Type | | | | | | | | Description | | | | | | +----------+--------------------------------------+---+ | | | | | code | | | | | | | | | | | | | integer | | | | | | | | The Oracle error number. | | | | | | | | | | | message | | | | | | | | | | | | | string | | | | | | | | The Oracle error text. | | | | | | | | | | | offset | | | | | | | | | | | | | integer | | | | | | | | The byte position of an error in | | | | the SQL statement. If there was no | | | | statement, this is 0 | | | | | | | | | | | sqltext | | | | | | | | | | | | | string | | | | | | | | The SQL statement text. If there | | | | was no statement, this is an empty | | | | string. | | | | | | +----------+--------------------------------------+---+ EXAMPLES
Example #1 Displaying the Oracle error message after a connection error <?php $conn = oci_connect("hr", "welcome", "localhost/XE"); if (!$conn) { $e = oci_error(); // For oci_connect errors do not pass a handle trigger_error(htmlentities($e['message']), E_USER_ERROR); } ?> Example #2 Displaying the Oracle error message after a parsing error <?php $stid = oci_parse($conn, "select ' from dual"); // note mismatched quote if (!$stid) { $e = oci_error($conn); // For oci_parse errors pass the connection handle trigger_error(htmlentities($e['message']), E_USER_ERROR); } ?> Example #3 Displaying the Oracle error message, the problematic statement, and the position of the problem of an execution error <?php $stid = oci_parse($conn, "select does_not_exist from dual"); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); // For oci_execute errors pass the statement handle print htmlentities($e['message']); print " <pre> "; print htmlentities($e['sqltext']); printf(" %".($e['offset']+1)."s", "^"); print " </pre> "; } ?> PHP Documentation Group OCI_ERROR(3)
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy