Sponsored Content
Full Discussion: text in columns
Top Forums Shell Programming and Scripting text in columns Post 302275266 by mierdatuti on Friday 9th of January 2009 03:10:25 PM
Old 01-09-2009
Quote:
Originally Posted by Franklin52
Try it with printf, something like:

Code:
printf "%-10s%-50s%-75s%-10s" $1 $2 $3 $4

Regards
Thanks!
But it doesn't works me:

Code:
awk: run time error: not enough arguments passed to printf("%-10s%-50s%-75s%-10s%1PlayBoy Cyber Club - Playmate Xtra HD Clips WEB-DL 720p H264 AAC-CtrlHDHD-Adulto (+18)6.58 GB")
        FILENAME="-" FNR=1 NR=1
awk: run time error: not enough arguments passed to printf("%-10s%-50s%-75s%-10s%2Lupin.3.El.Castillo.de.Cagliostro.720.bluray[HDCity.es][PS3Team].m2tsHD-PS34.30 GB")
        FILENAME="-" FNR=1 NR=1
awk: run time error: not enough arguments passed to printf("%-10s%-50s%-75s%-10s%3Los hombres de Paco 7x01 [DVBRip] [DIVX]Series699.44 MB")

I try:

echo $Line | awk 'BEGIN {FS="#"} {printf "%-10s%-50s%-75s%-10s%" $1 $2 $3 $4}'

Last edited by mierdatuti; 01-09-2009 at 04:21 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Text formatting to 132 columns

I want to take a file that is generated in 132 columns from a unix based report generator and transfer it to a windows environment and preserve the column length. Any ideas how I can do this so that whatever windows based text editor that reads the document will know it should be in 132 columns?... (16 Replies)
Discussion started by: jmossman
16 Replies

2. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

3. Shell Programming and Scripting

Can I use columns from text files in if statements?

Currently I am stuck on my program for my if statement, as I do not no how to get a specific collumn of text to check against my variable. df -k /home/* > fd.txt cat df.txt | tr -s " " | awk '{print $3, $4, $1}' > dfcap.txt echo -n "Enter the size (in kilobytes) you wish to check against... (18 Replies)
Discussion started by: ninjafish
18 Replies

4. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

5. Shell Programming and Scripting

Transpose few columns alone in a Text file

Hi Friends, I am Stuck up with a problem on transposing Rows to Coloumns.. Though there are many threads on this my problem is little difficult.. I have a tab separated file like Below, computer selling_loc currency_type manufacturer_name salesweek-wk1 sales-wk2 ...wk-3 ..wk4 till... (7 Replies)
Discussion started by: heinz_holan
7 Replies

6. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies

7. Programming

Read columns from text files

Dear All, I have basic structure of the C++ code . It suppose to read particular columns from some txt file. The txt file look like following (snippet). I have to ask the details for instance 'id' information for rows satisfying text with red color. The issue is that the txt file has not just the... (2 Replies)
Discussion started by: emily
2 Replies

8. Shell Programming and Scripting

Text columns processing using awk

P { margin-bottom: 0.25cm; line-height: 120%; }CODE.cjk { font-family: "WenQuanYi Micro Hei",monospace; }CODE.ctl { font-family: "Lohit Hindi",monospace; }A:link { } I'm trying to build an awk statement to print from a file (file1): A 1,2,3 * A 4,5,6 ** B 1 ... (4 Replies)
Discussion started by: dovah
4 Replies

9. Shell Programming and Scripting

Replace text in columns

I have two files in below formats: cat file1 abc|abcd|10|1020 10|xyz|1010|1020 abc|abcd|10|1020 10|xyz|1010|1020 cat file2 abc|abcd|10|1020 11|xyz|1010|1020 abc|abcd|12|1020 10|xyz|1011|1020 abc|abcd|11|1020 10|xyz|1010|1020 abc|abcd|10|1020 10|xyz|1010|1020 I am generating a... (3 Replies)
Discussion started by: ctrld
3 Replies

10. UNIX for Beginners Questions & Answers

Convert text to columns

Hi. I need an input file of a single word pr. line converted in into a list of random pairs. i need input like this word1 word2 word3 word4 to be outputted like this: word3 word1 word2 word4 My attempt is a tedious while loop like this: nfiles=$(cat inputfile | wc -l) ... (4 Replies)
Discussion started by: BotHead
4 Replies
DB2_FETCH_ASSOC(3)							 1							DB2_FETCH_ASSOC(3)

db2_fetch_assoc - Returns an array, indexed by column name, representing a row in a result set

SYNOPSIS
array db2_fetch_assoc (resource $stmt, [int $row_number = -1]) DESCRIPTION
Returns an array, indexed by column name, representing a row in a result set. PARAMETERS
o $stmt - A valid stmt resource containing a result set. o $row_number - Requests a specific 1-indexed row from the result set. Passing this parameter results in a PHP warning if the result set uses a forward-only cursor. RETURN VALUES
Returns an associative array with column values indexed by the column name representing the next or requested row in the result set. Returns FALSE if there are no rows left in the result set, or if the row requested by $row_number does not exist in the result set. EXAMPLES
Example #1 Iterating through a forward-only cursor If you call db2_fetch_assoc(3) without a specific row number, it automatically retrieves the next row in the result set. <?php $sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed"; $stmt = db2_prepare($conn, $sql); $result = db2_execute($stmt); while ($row = db2_fetch_assoc($stmt)) { printf ("%-5d %-16s %-32s %10s ", $row['ID'], $row['NAME'], $row['BREED'], $row['WEIGHT']); } ?> The above example will output: 0 Pook cat 3.20 5 Rickety Ride goat 9.70 2 Smarty horse 350.00 Example #2 Retrieving specific rows with db2_fetch_assoc(3) from a scrollable cursor If your result set uses a scrollable cursor, you can call db2_fetch_assoc(3) with a specific row number. The following example retrieves every other row in the result set, starting with the second row. <?php $sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed"; $result = db2_exec($stmt, $sql, array('cursor' => DB2_SCROLLABLE)); $i=2; while ($row = db2_fetch_assoc($result, $i)) { printf ("%-5d %-16s %-32s %10s ", $row['ID'], $row['NAME'], $row['BREED'], $row['WEIGHT']); $i = $i + 2; } ?> The above example will output: 0 Pook cat 3.20 5 Rickety Ride goat 9.70 2 Smarty horse 350.00 SEE ALSO
db2_fetch_array(3), db2_fetch_both(3), db2_fetch_object(3), db2_fetch_row(3), db2_result(3). PHP Documentation Group DB2_FETCH_ASSOC(3)
All times are GMT -4. The time now is 09:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy