Sponsored Content
Top Forums Shell Programming and Scripting Change a file content format using awk Post 302760905 by fastlane3000 on Thursday 24th of January 2013 06:18:51 PM
Old 01-24-2013
Change a file content format using awk

Hi,
i have a file input.txt
Code:
Continent North America
Country USA Capital Washington D.C.
Country Canada Capital Ottawa
Continent South America
Country Argentina Capital Buenos Aires
Country Brazil     Capital Brasília 
Coutry Colombia Capital Bogotá

and i want to get an output.txt

Code:
Continent North America Country USA Capital Washington D.C.
Continent North America Country Canada Capital Ottawa
Continent South America Country Argentina Capital Buenos Aires
Continent South America Country Brazil Capital Brasília 
Continent South America Country Colombia Capital Bogota

Thank's for your help

(i'm using AIX 5.3 with ksh88)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

change field content awk

I have a line like this: I want to move HTTP/1.1 200 OK to the next line and put a blank line between the two lines i.e. How can i get it using awk? Thanks in advance (2 Replies)
Discussion started by: littleboyblu
2 Replies

2. UNIX for Dummies Questions & Answers

Content format in a text file

Hi, I need to format the content in a text file as below format. Can some one help me how to approach? Also whether is it possible to convert the output to excel in column wise? Present: ============================================================================= Name: vinodh Status:... (1 Reply)
Discussion started by: vino_hymi
1 Replies

3. Shell Programming and Scripting

awk,cut fields by change field format

Hi Everyone, # cat 1.txt 1321631,77770132976455,19,20091001011859,20091001011907 1321631,77770132976455,19,20091001011859,20091001011907 1321631,77770132976455,19,20091001011859,20091001011907 # cat 1.txt | awk -F, '{OFS=",";print $1,$3,$4,$5}' 1321631,19,20091001011859,20091001011907... (7 Replies)
Discussion started by: jimmy_y
7 Replies

4. Shell Programming and Scripting

How can I change is output format by awk ?

Hello, Can you tell me how can I change this format by awk Input 0.2057422D-01 0.2463722D-01 -0.1068047D-02 Output 0.02057422 0.02463722 -0.001068047 Thanks wan (8 Replies)
Discussion started by: wanchem
8 Replies

5. Shell Programming and Scripting

using awk or bash to change the format

tenxun-glibc_code-x86-64-linux-20120713190049.root.tar.bz2 To tenxun-glibc_code-x86-64-linux.root.tar.bz2 (3 Replies)
Discussion started by: yanglei_fage
3 Replies

6. Shell Programming and Scripting

awk - change date format

I have below date format in a CSV file. (dd/mm/yyyy) Ex Input: 9/8/2013 Need to convert it into below format (yyyymmdd ) and redirect to new file. Ex Output: 20130809 How do I use awk here to change the format and if leading 0 (zero) is not then add it. Please help. Thanks. (8 Replies)
Discussion started by: vegasluxor
8 Replies

7. UNIX for Dummies Questions & Answers

Use awk to change an IP format

Basically I am trying to run a standard output of IP address with a port number into another command but I need to change it from. 74.125.224.194.80 into 74.125.224.194:80 One command wants a period before the port the subsequent one wants a colon. So is there anyway I can feed... (3 Replies)
Discussion started by: MrEddy
3 Replies

8. Shell Programming and Scripting

Datestamp format 2nd change in csv file (awk or sed)

I have a csv file formatted like this: 2014-08-21 18:06:26,A,B,12345,123,C,1232,26/08/14 18:07and I'm trying to change it to MM/DD/YYYY HH:MM for both occurances. I have got this: awk -F, 'NR <=1 {print;next}{"date +%d/%m/%Y\" \"%H:%m -d\""$1 "\""| getline dte;$1=dte}1' OFS="," test.csvThis... (6 Replies)
Discussion started by: say170
6 Replies

9. Shell Programming and Scripting

Need to change date format in a csv file using awk

Example: Input csv file 00245DLS,Sitel Ocala,12/31/2014,18:45,1.00,7.00,0.00,0.00 00245DLS,Sitel Ocala,12/31/2014,19:00,-1.00,-1.00,-1.00,-1.00 00245HB,Charlotte,01/01/2015,00:00,-1.00,-1.00,-1.00,0.00 Output csv file 00245DLS,Sitel Ocala,2014/12/31,18:45,1.00,7.00,0.00,0.00 00245DLS,Sitel... (8 Replies)
Discussion started by: adit
8 Replies

10. UNIX for Beginners Questions & Answers

Date format conversion how to change this from using nawk to awk

Hi, I have a file where I need to change the date format on the nth field from DD-MM-YYYY to YYYY-MM-DD so I can accurately sort the record by dates From regex - Use sed or awk to fix date format - Stack Overflow, I found an example using nawk. Test run as below: $: cat xyz.txt A ... (2 Replies)
Discussion started by: newbie_01
2 Replies
MYSQLI_STMT_GET_RESULT(3)						 1						 MYSQLI_STMT_GET_RESULT(3)

mysqli_stmt::get_result - Gets a result set from a prepared statement

       Object oriented style

SYNOPSIS
mysqli_result mysqli_stmt::get_result (void ) DESCRIPTION
Procedural style mysqli_result mysqli_stmt_get_result (mysqli_stmt $stmt) Call to return a result set from a prepared statement query. PARAMETERS
o $ stmt -Procedural style only: A statement identifier returned by mysqli_stmt_init(3). RETURN VALUES
Returns a resultset or FALSE on failure. MYSQL NATIVE DRIVER ONLY
Available only with mysqlnd. EXAMPLES
Example #1 Object oriented style <?php $mysqli = new mysqli("127.0.0.1", "user", "password", "world"); if($mysqli->connect_error) { die("$mysqli->connect_errno: $mysqli->connect_error"); } $query = "SELECT Name, Population, Continent FROM Country WHERE Continent=? ORDER BY Name LIMIT 1"; $stmt = $mysqli->stmt_init(); if(!$stmt->prepare($query)) { print "Failed to prepare statement "; } else { $stmt->bind_param("s", $continent); $continent_array = array('Europe','Africa','Asia','North America'); foreach($continent_array as $continent) { $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_array(MYSQLI_NUM)) { foreach ($row as $r) { print "$r "; } print " "; } } } $stmt->close(); $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect("127.0.0.1", "user", "password", "world"); if (!$link) { $error = mysqli_connect_error(); $errno = mysqli_connect_errno(); print "$errno: $error "; exit(); } $query = "SELECT Name, Population, Continent FROM Country WHERE Continent=? ORDER BY Name LIMIT 1"; $stmt = mysqli_stmt_init($link); if(!mysqli_stmt_prepare($stmt, $query)) { print "Failed to prepare statement "; } else { mysqli_stmt_bind_param($stmt, "s", $continent); $continent_array = array('Europe','Africa','Asia','North America'); foreach($continent_array as $continent) { mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { foreach ($row as $r) { print "$r "; } print " "; } } } mysqli_stmt_close($stmt); mysqli_close($link); ?> The above examples will output: Albania 3401200 Europe Algeria 31471000 Africa Afghanistan 22720000 Asia Anguilla 8000 North America SEE ALSO
mysqli_prepare(3), mysqli_stmt_result_metadata(3), mysqli_stmt_fetch(3), mysqli_fetch_array(3), mysqli_stmt_store_result(3). PHP Documentation Group MYSQLI_STMT_GET_RESULT(3)
All times are GMT -4. The time now is 11:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy