Sponsored Content
Full Discussion: printf to format lines.
Top Forums Shell Programming and Scripting printf to format lines. Post 302374680 by gcampton on Wednesday 25th of November 2009 08:12:38 AM
Old 11-25-2009
Quote:
Originally Posted by Scrutinizer
Code:
printf "%5d %30s %30s\n" "$arg3" "$arg2" "$arg1"

thnx, the %5d works, it makes it right justified as default, anyway to make the other two left justified?
damn man pages why couldn't they make them easier to understand :S
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printf format

hi, i would like to extract the header and put it in a variable, then use printf to output the variable, but i keep on getting errors...please tell me if my format is incorrect. HDR = "`ps -e -o user,pid,ppid,pcpu,stime,etime,time,comm | head -n 1`" printf (%s, $HDR); thanks! (3 Replies)
Discussion started by: laila63
3 Replies

2. Shell Programming and Scripting

awk printf formatting using string format specifier.

Hi all, My simple AWK code does C = A - B If C can be a negative number, how awk printf formating handles it using string format specifier. Thanks in advance Kanu :confused: (9 Replies)
Discussion started by: kanu_pathak
9 Replies

3. Shell Programming and Scripting

Format data in new lines

Hi All, I have data in the following format. Australia,"CISCO877-SEC-K9 CISCO1841-ADSL CISCO2821" Australia,"CISCO877-SEC-K9 CISCO1841-ADSL CISCO2821" Austria,"CISCO871-K9 CISCO1841 CISCO1841-SEC/K9 CISCO1812/K9" Austria,"CISCO1841-SEC/K9 CISCO1812/K9" (3 Replies)
Discussion started by: rahulrathod
3 Replies

4. Shell Programming and Scripting

How to format the output using float in awk{printf}

Hi I'm using awk to manipulate the data in the 6th field of the file xxx_yyy.hrv. The sample data that is available in this field is given below 220731.7100000000000000 When i tried using this command cat xxx_yyy.hrv | awk '{printf("%23.16f\n",$6*-1)}' I get the output as... (4 Replies)
Discussion started by: angelarosh
4 Replies

5. Shell Programming and Scripting

changing all the lines in one format

Hi, I am beginner. have almost one text file which contains 6000 lines. every line is in different format.so need to rearrange in single format. Ex: .thde.adgtmk.802ati thde.kghijk..567ati ..thde.kghijk..458ati thde.ertyui.456.567.789ati thde.awse.dati Rules:... (2 Replies)
Discussion started by: kartheek
2 Replies

6. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

7. Shell Programming and Scripting

format lines on a file

Hi again: I have a log file wihch has always this format: DATA line 1 DATA line 2 ^^^^^ | Spaces or TABs The first line always begins from the start, but the second begins with spaces or TABs, Question: How can I add the second line to the first one? I mean this: DATA... (6 Replies)
Discussion started by: iga3725
6 Replies

8. UNIX for Dummies Questions & Answers

awk printf in required format

Hi my awk variable $0 contains the below data Input file 000001 The Data 000002* The line 2 000003* The line3 output file Req 000001* The Data 000002** The line 2 000003** The line3 one * at column seven needs to be appended to the input lines, (5 Replies)
Discussion started by: rakeshkumar
5 Replies

9. Shell Programming and Scripting

awk printf format in columns

Hi all, i have written this script: awk -F';' ' BEGIN { printf "\n" printf "\n" printf "\n" printf "----------------------------------------------\n" print " For test " printf "----------------------------------------------\n" test_200 = 0 test_300 = 0 test_500 = 0 test_1000 = 0... (11 Replies)
Discussion started by: arrals_vl
11 Replies

10. Shell Programming and Scripting

printf format with awk

Hello Here is an easy one Data file 12345 (tab) Some text (tab) 53.432 23456 (tab) Some longer text (tab) 933.422 34567 (tab) Some different text (tab) 29.309 I need to awk these three tab-delimited columns so that the first two are unchanged (unformatted) and the third shows two decimal... (1 Reply)
Discussion started by: palex
1 Replies
shevek::istring(3)					     Library Functions Manual						shevek::istring(3)

NAME
shevek::istring - shevek::istring is a C++ version of scanf. SYNOPSIS
#include <iostring.hh> Public Member Functions istring () Create a new istring with no data. istring (Glib::ustring const &str) Create a new istring with data. void init (Glib::ustring const &str) Set new data to an existing istring. void push () Push the current position to the stack so it can be restored later. int pop (bool keep=false) Pop the last pushed position from the stack. void reset () Set the current position to 0, but don't change the stack. Glib::ustring rest () const Get remaining string. void skip (Glib::ustring::size_type p) Skip some characters. bool operator() (Glib::ustring const &format) Read a constant string from the input. template<typename T1 > bool operator() (Glib::ustring const &format, T1 &arg1) Read a string containing one argument from the input. template<typename T1 , typename T2 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2) Read a string containing two arguments from the input. template<typename T1 , typename T2 , typename T3 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3) Read a string containing three arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4) Read a string containing four arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5) Read a string containing five arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6) Read a string containing six arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7) Read a string containing seven arguments from the input. template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > bool operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7, T8 &arg8) Read a string containing eight arguments from the input. Static Public Member Functions template<typename T > static T direct (Glib::ustring const &data, Glib::ustring const &format, T def=T()) Read a variable from given data and return it. Detailed Description shevek::istring is a C++ version of scanf. It uses templates to allow expanding it to user-defined types, but it still uses a format string to make it better translatable. Member Function Documentation template<typename T > static T shevek::istring::direct (Glib::ustring const &data, Glib::ustring const &format, Tdef = T ()) [inline, static] Read a variable from given data and return it. This allows using a shevek::istring in an expression without the need to create a new variable for it. If the input doesn't match the format, def is returned. int shevek::istring::pop (boolkeep = false) Pop the last pushed position from the stack. If keep is true or not given, the current position is restored to the last position. If it is false, the current position is not changed. Author Generated automatically by Doxygen for libshevek from the source code. libshevek Fri May 11 2012 shevek::istring(3)
All times are GMT -4. The time now is 03:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy