Sponsored Content
Top Forums Shell Programming and Scripting [BASH] Performance question - Script to STDOUT Post 302907630 by Chubler_XL on Monday 30th of June 2014 03:47:39 PM
Old 06-30-2014
I'm not entirely sure what these aliments are supposed to look like but this version fills on either side of each argument to your cliWidth and could be a good example/starting point for you:

Code:
    sP() {
        lentotal=$cliWidth
        lenborders=$(( ${#bl} + ${#br} ))
        argstr="$@"
        lenargs=$(( ${#argstr} - $# + 1))
        SPACES=$(( lentotal - lenborders - lenargs - 2))
        if [ $SPACES -gt $# ]
        then
            # Room for args on single line
            printf -v spc "%*s" $((SPACES / ($# + 1))) ""
            printf -v str "$spc%s" $@
            printf "\r%s %-*s %s" "$bl" $((lenargs + SPACES)) "$str" "$br"
        else
            # Need more than 1 line here
        fi
    }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BASH shell script question

I want to make shell script that takes a list of host names on my network as command line arguments and displays whether the hosts are up or down, using the ping command to display the status of a host and a for loop to process all the host names. Im new to shell scripting so Im not quite sure... (3 Replies)
Discussion started by: ewarmour
3 Replies

2. Shell Programming and Scripting

one question for bash shell script

Just one question for bash shell script. In bash script, you can use *.txt to call any files in current folder that ends with .txt, like rm *.txt will remove all txt file in current folder. My question is can you actually remember or use the file name among *.txt, I know file=*.txt will not... (9 Replies)
Discussion started by: zx1106
9 Replies

3. Shell Programming and Scripting

BASH script question

Hi, I want to create a script that gets a filename as an argument. The script should generate a listing in long list format of the current directory, sorted by file size. This list must be written to a new file by the filename given on the command line. Can someone help me with this? ... (6 Replies)
Discussion started by: I-1
6 Replies

4. Shell Programming and Scripting

bash script question

Can anybody be kind to explaing me what the lines below mean ? eval line=$line export $line ] || echo $line (2 Replies)
Discussion started by: jville
2 Replies

5. Shell Programming and Scripting

bash, help with stdout manipulation.

Hey all, Im kind of lost on how to do what I want so I figured I would ask. I want to pipe STDOUT of an app to a log file, but I want to prepend each line of that output with the date and time. Im drawing a complete blank on how to do this?? Any ideas? i.e. output is currently this:... (9 Replies)
Discussion started by: trey85stang
9 Replies

6. Shell Programming and Scripting

Mkbootfs writing to stdout in bash script

Hi, I need to automate some repacking tasks of a boot image for Android When in command line, I can use this command: mkbootfs /path/to/root > /path/to/ramdisk-recovery.cpio;However, if I try to run the command from a shell script under Ubuntu, it fails and outputs to stdout instead of the... (27 Replies)
Discussion started by: Phil3759
27 Replies

7. Shell Programming and Scripting

Question in bash script.

Hi All, I need an assistance with the issue below. I wrote big script in "bash" that automatically install an LDAP on Clients. I'd be happy to know in order to avoid duplication of entries in files, How i can define into the script, if the specific expressions already exist in the file, do... (7 Replies)
Discussion started by: Aviel.shani
7 Replies

8. Shell Programming and Scripting

Question about writing a bash script

Hello, I want to write a bash script to delete the content after '#'. However, if '#' appears in a string with "", ignore this. For example, input file: test #delete "test #not delete" Output file: test "test #not delete" Does anyone know how to write this script? Thanks (1 Reply)
Discussion started by: jeffwang66
1 Replies

9. Shell Programming and Scripting

Bash Script Iterating Question

I am trying to look through one of my directories to remove certain files. I am pretty new to Unix and bash so I just need a little help in starting this. I know I would have to write two loops one to iterate the directories and one to iterate the files. How would I write the loops? (3 Replies)
Discussion started by: totoro125
3 Replies

10. Shell Programming and Scripting

Bash script search, improve performance with large files

Hello, For several of our scripts we are using awk to search patterns in files with data from other files. This works almost perfectly except that it takes ages to run on larger files. I am wondering if there is a way to speed up this process or have something else that is quicker with the... (15 Replies)
Discussion started by: SDohmen
15 Replies
NETTOE(6)							   Games Manual 							 NETTOE(6)

NAME
nettoe - Networked version of Tic Tac Toe for the console SYNOPSIS
nettoe [OPTIONS] DESCRIPTION
netToe is a console-based version of the classic game "Tic Tac Toe". It's playable against computer AI, a player on the same machine or with another player over the network. OPTIONS
-nc, --no-colors disable colors -nb, --no-beep disable beeps -h, --help display this help and exit -v, --version output version information and exit HOW TO PLAY
First decide who will host the game. (you or your friend/opponent) Now the one who is going to host the game must (do the following): 1. run nettoe (Doh) 2. choose the option 3 (Two players over network) from the Main Menu 3. choose the option 1 (Host the Game) from the Network Game Menu 4. type in his name or nickname (NO BLANK SPACES ALLOWED). 5. comunicate the IP address to the other player. ( hostname also works... if resolved, of course) ( I hope you know how to get your IP address...) 6. Just wait for the other player to connect to your host. Now for the other player (the one who is going to connect to the hosted game ): 1. run nettoe (really ?, Yaeh relly.) 2. choose the option 3 (Two players over network) from the Main Menu 3. choose the option 2 (Connect to a host) from the Network Game Menu 4. type your name or nickname (NO BLANK SPACES ALLOWED). 5. type in the IP address of the host or the hostname. IP address examples: 192.168.0.5, ::1 Hostname example : myfriend.hostname.com (must be a valid hostname) 6. Just wait for the game to start . Enjoy. And if you have any problem just let me know. NETWORK PORTS
netToe uses tcp-port 7501 for listening port of the server engine. Thus this port must be transportable across the network, possibly pass- ing routers in the path. For a local game this is of course mostly irrelevant. AVAILABILTY
The latest version of this program can be found at http://nettoe.sourceforge.net BUGS
See the BUGS file in the netToe source package for a list of known bugs. Report bugs to <ggdev@users.sourceforge.net> AUTHOR
netToe is written by Gabriele Giorgetti <ggdev@users.sourceforge.net> This manual page was initially written by Andras Bali <bali@debian.org>, for the Debian GNU/Linux system and rewritten by Gabriele Gior- getti <ggdev@users.sourceforge.net> to be distributed within the netToe source package. COPYRIGHT
Copyright (C) 2000,2001 Gabriele Giorgetti This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. JULY 22, 2001 NETTOE(6)
All times are GMT -4. The time now is 05:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy