Sponsored Content
Top Forums Shell Programming and Scripting awk - print formatted without knowing no of cols Post 302087059 by vgersh99 on Tuesday 29th of August 2006 03:04:10 PM
Old 08-29-2006
Code:
#!/bin/bash

awk '{
  for ( i=1; i<=NF; i++)
     printf("%s%s", $i, (i==NF) ? "\n" : "\t")
}' $1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatted output - awk

Hi I have the following records in a file SABN YOURTUBE 000514 7256 SACN XYOUDSDF 000514 7356 SADN KEHLHRSER 000514 7656 SAEN YOURTUBE 000514 7156 SAFN YOURTUBE 000514 7056 I need to put this in the format like this printf '%s %-50s %6s %-6s\n' I am not going to read individual... (3 Replies)
Discussion started by: dhanamurthy
3 Replies

2. UNIX for Dummies Questions & Answers

Problem with formatted printing in AWK

Hi, I want to print 130 fileds using formatted printing in AWK. It looks like awk '{printf ("%7.2f%7.2f...%7.2\n",$1,$2,...,$130)}' inflie>oufile But it gives me an error: Word too long! Can you please help me with this? Is there another way to do this? (1 Reply)
Discussion started by: PHL
1 Replies

3. Shell Programming and Scripting

output - tab formatted - awk

Dear All, Good Day. I would like to hear your suggestions for the following problem: I have a file with 5 columns with some numbers in 16 lines as shown below. Input file: Col 1 Col 2 Col 3 Col 4 Col 5 12 220 2 121 20 234 30 22 9... (3 Replies)
Discussion started by: Fredrick
3 Replies

4. Shell Programming and Scripting

print formatted text to the printer

Hello!!! I am using shell script that print some formated text on the screen (example) ======== hello I am ... ======== Is it possible to print this information to the printer exactly as I see it on the screen??? (6 Replies)
Discussion started by: tdev457
6 Replies

5. Shell Programming and Scripting

awk -- print combinations for 2 cols

Dear all, could you please help me with awk please? I have such input: Input: a d b e c f The number of lines is unknown before reading the file. I need to print possible combination between the two columns like this: Output: a d b d c d a e b e c e a f (2 Replies)
Discussion started by: irrevocabile
2 Replies

6. Shell Programming and Scripting

awk split lines without knowing the number of fields a-priori

I want to use awk to split fields and put them into a file but I don't know the number of fields for example, in the following line Ports: 22/filtered/tcp//ssh///, 53/open/tcp//tcpwrapped///, 111/filtered/tcp//rpcbind///, 543/filtered/tcp//klogin///, 544/filtered/tcp//kshell///,... (3 Replies)
Discussion started by: esolvepolito
3 Replies

7. Shell Programming and Scripting

Problems with awk printf, formatted output

Hi, i have a script, which is incomplete, am on my way developing it. Input 1,12,2012,IF_TB001 2,12,2012,3K3 3,Z56,00000,25,229,K900,00, ,3G3, ,USD, ,0000000000,000, , , , 550000000 3,Z56,00000,53,411,W225,00,000, , ,USD,OM170,0000000000,000, , , , -550000000 4,Z56,COUNT, 4,SUM LOC,... (19 Replies)
Discussion started by: selvankj
19 Replies

8. Shell Programming and Scripting

As knowing which version has the awk?

friends How do I know which version of awk using my linux? (2 Replies)
Discussion started by: tricampeon81
2 Replies

9. Shell Programming and Scripting

awk operation to get table formatted file

I need to parse .conf file in Unix system to get output from the snippets like below : ; generated by mod_identity exten => int,1,GoSub(mdc_template-3,s,1) exten => int,n(next_380),Return() ; default action for busy exten => ext,1,GoSub(mdc_template-3,s,1) exten => ext,n,Set(PRI_CAUSE=17)... (2 Replies)
Discussion started by: cheecky
2 Replies

10. Shell Programming and Scripting

Processing a formatted file with awk

Hi - I want to interrogate information about my poker hands, sessions are all recorded in a text file in a particular format. Each hand starts with the string <PokerStars> followed by a unique hand reference and other data like date/time. There is then all the information about each hand. My first... (5 Replies)
Discussion started by: rbeech23
5 Replies
xscreensaver-text(1)                                            XScreenSaver manual                                           xscreensaver-text(1)

NAME
xscreensaver-text - prints some text to stdout, for use by screen savers. SYNOPSIS
xscreensaver-text [--verbose] [--columns N] [--text STRING] [--file PATH] [--program CMD] [--url URL] DESCRIPTION
The xscreensaver-text script prints out some text for use by various screensavers, according to the options set in the ~/.xscreensaver file. This may dump the contents of a file, run a program, or load a URL. OPTIONS
xscreensaver-text accepts the following options: --columns N or --cols N Where to wrap lines; default 72 columns. --verbose or -v Print diagnostics to stderr. Multiple -v switches increase the amount of output. Command line options may be used to override the settings in the ~/.xscreensaver file: --string STRING Print the given string. It may contain % escape sequences as per strftime(2). --file PATH Print the contents of the given file. If --cols is specified, re-wrap the lines; otherwise, print them as-is. --program CMD Run the given program and print its output. If --cols is specified, re-wrap the output. --url HTTP-URL Download and print the contents of the HTTP document. If it contains HTML, RSS, or Atom, it will be converted to plain-text. Note: this re-downloads the document every time it is run! It might be considered abusive for you to point this at a web server that you do not control! ENVIRONMENT
HTTP_PROXY or http_proxy to get the default HTTP proxy host and port. BUGS
The RSS and Atom output is always ISO-8859-1, regardless of locale. URLs should be cached, use "If-Modified-Since", and obey "Expires". SEE ALSO
xscreensaver-demo(1), xscreensaver(1), fortune(1), phosphor(1), apple2(1), starwars(1), fontglide(1), dadadodo(1), webcollage(1), http://www.livejournal.com/stats/latest-rss.bml, http://twitter.com/statuses/public_timeline.atom, driftnet(1), EtherPEG, EtherPeek COPYRIGHT
Copyright (C) 2005 by Jamie Zawinski. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. AUTHOR
Jamie Zawinski <jwz@jwz.org>, 20-Mar-2005. X Version 11 5.15 (28-Sep-2011) xscreensaver-text(1)
All times are GMT -4. The time now is 08:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy