Sponsored Content
Top Forums Shell Programming and Scripting Allign the text result of a for/next cicle Post 302898961 by Lord Spectre on Friday 25th of April 2014 08:08:26 AM
Old 04-25-2014
Allign the text result of a for/next cicle

Dear community,
probably is quite easy, but I'm scratching my head to find a solution on Red Hat bash. What I have to do is to allign the result of a for/next cicle, something like:

Code:
$ printf("%-5s %05x %5d\n", $next, $Server, $Client)
-sh: syntax error near unexpected token `"%-5s %05x %5d\n",'

This because without formatting I got:
Code:
ID: 1234 Server: 10 Client: 20
ID: 123 Server: 200 Client: 30
ID: 12345 Server: 1200 Client: 1

And I would like to have something like:
Code:
ID: 1234   Server: 10    Client: 20
ID: 123    Server: 200   Client: 30
ID: 12345  Server: 1200  Client: 1

Thanks who can help me! Smilie
Lucas
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Allign text html

Hi All How do I allign these lines html,thank you <span class="time"><strong> 06:00 </strong></span> <div class="cDesc" style="display: none"> TEXTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT </div> <div class="cTitle" style="display: none"> ... (3 Replies)
Discussion started by: Novice-
3 Replies

2. Shell Programming and Scripting

for cicle and awk

Hi, I wrote the following script: #! /bin/bash for ((i = 1600; i < 3700; i = i + 100)) do awk '{if ($16 > "'$i'"-101 && $16 < "'$i'") print $0 }' prova > prova1 done which is supposed to print, from the original file "prova" in the new file prov1 , only the data that at the... (2 Replies)
Discussion started by: danile
2 Replies

3. Shell Programming and Scripting

Allign the output

Hi I have an SQL which returns me the o/p as below in an unformatted manner Table Size No. ============================================= DEF 22 2 PAF 3 1 99D 12 1 USERS 6 1 04D 4 ... (4 Replies)
Discussion started by: jjoy
4 Replies

4. Shell Programming and Scripting

Displaying Result to a Text File

Hi; I am scripting in Shell and i want to write output (on screen) to a text file? ... | tee gcsw/output.txt doesnot work? :(:( (6 Replies)
Discussion started by: gc_sw
6 Replies

5. Shell Programming and Scripting

Append Text in Result File Name

Hi Below command is returning the list of files which having this string "MTL_SYSTEM_ITEMS". find . -name "*"|xargs grep -il MTL_SYSTEM_ITEMS Ex: Above command is returing 2 files (Out of 10 files 2 files having this string). ./file1.txt and ./file2.txt Here I want to append... (3 Replies)
Discussion started by: balajiora
3 Replies

6. Shell Programming and Scripting

How to output thre result to a text file?

Dear All I have a script file like the following: ..... ..... Variable_1 = 888 Variable_2 = 999 ..... MyExternalProgram Myfile ..... The line MyExternalProgram Myfile will generate some number, Say 777 Now I hope I can output the result of above codes to a text file,... (2 Replies)
Discussion started by: littlewenwen
2 Replies

7. Shell Programming and Scripting

How to allign output data in UNIX that is separated with a pipe "|" symbol ?

Experts , In the given output of the log file, the 2nd field that is separated by "|" pipe is not aligned well due to the uneven data length, I would like it to align the 2nd column with 37 length (that is disturbed in the output) including the pipe . The two pepe "|" would be in a aligned way... (2 Replies)
Discussion started by: rveri
2 Replies

8. Shell Programming and Scripting

Save result to a text file

Currently I have a perl code to combine two different files. #! /usr/bin/perl -w use strict; open FP1,"A.txt"; open FP2,"B.txt"; my ($l1,$l2); while(1) { $l1=<FP1>; chomp $l1; $l2=<FP2>; chomp $l2; last unless(defined $l1 or defined $l2); print "$l1 $l2\n"; } close FP2;... (4 Replies)
Discussion started by: Tzeronone
4 Replies

9. Shell Programming and Scripting

awk to parse file and display result based on text

I am trying using awk to open an input file and check a column 2/field $2 and if there is a warning then that is displayed (variantchecker): G not found at position 459, found A instead. The attached Sample1.txt is that file. If in that column/field there is a black space, then the text after... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. Shell Programming and Scripting

Average result of text file

Hi all I have created a script to allow me to gain a number of file times and how long they take to execute. I have been asked to get the average time for the log. The log will update every 5 minutes and never be empty. 141 152 157 161 168 169 171 179 202 207 229 651 666 714... (3 Replies)
Discussion started by: simpsa27
3 Replies
ATF-SH(1)						    BSD General Commands Manual 						 ATF-SH(1)

NAME
atf-sh [-s shell] -- interpreter for shell-based test programs SYNOPSIS
atf-sh script DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library. atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter- preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not use any non-standard extensions. The following options are available: -s shell Specifies the shell to use instead of the value provided by ATF_SHELL. ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes. ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes. ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a specific interpreter. EXAMPLES
Scripts using atf-sh(3) should start with: #! /usr/bin/env atf-sh Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode the path to atf-sh in the script and then use the -s option afterwards as a single parameter: #! /path/to/bin/atf-sh -s/bin/bash ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts. SEE ALSO
atf-sh(3) BSD
September 27, 2014 BSD
All times are GMT -4. The time now is 10:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy