Sponsored Content
Operating Systems OS X (Apple) Plotting A Sine Curve Inside A Bash Shell... Post 302914573 by Corona688 on Tuesday 26th of August 2014 05:28:54 PM
Old 08-26-2014
Interesting. You could roll it all up in awk, which I think is preferable, especially in Windows, which reacts badly to launching thousands of tiny short-lived processes:

Code:
$ awk '
 function qsin(X) {
         return(int((G/2)+(sin(X*(3.14159/180))*(G/2))))
 }

 BEGIN {
         if(!Q) Q=5; # 360/5 width
         if(!G) G=20; # 20 rows height

         for(M=0; M<G; M++) for(N=0; N<360; N+=Q) A[N,M]=" ";
         for(N=0; N<360; N+=Q) A[N,qsin(N)]="*";
         for(M=0; M<G; printf("\n", M++) ) for(N=0; N<360; N+=Q)
                 printf("%s", A[N,M]);
 }' /dev/null

                                                 ***********
                                               **           **
                                             **               **
                                            *                   *
                                           *                     **
                                         **                        *
                                        *                           *
                                       *                             *
                                      *                               *
                                     *                                 *
**                                 **
  *                               *
   *                             *
    *                           *
     **                        *
       *                     **
        *                   *
         **               **
           **           **
             ***********

$

awk can also output binary via printf("%c", 65); and the like.

Last edited by Corona688; 08-26-2014 at 06:35 PM..
This User Gave Thanks to Corona688 For This Post:
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[BASH] redirect standard error and use it inside

Hi all, Maybe my question is too simple but till now i couldn't figure about a solution :( I have a bash script scheduled in cron: <cron time parameters> my_script.sh > result.log 2>&1 By this way i can have standard output and standard error in my result.log file Now i want my script... (2 Replies)
Discussion started by: Pescator
2 Replies

2. Shell Programming and Scripting

running bash command inside awk

Org file 192.168.1.10 d:\adir\xdir 192.168.1.11 d:\bdir\ydir want to covert it into robocopy \\192.168.1.10\d$\adir\xdir\log* some_localdir\adir robocopy \\192.168.1.10\d$\adir\ydir\log* some_localdir\bbdir (5 Replies)
Discussion started by: ydk
5 Replies

3. UNIX for Dummies Questions & Answers

using awk inside bash script?

Hello, I'm trying to write a bash script that will query the current system time (OS X 10.6.6) and then convert the output from HH:MM:SS into time in seconds. The output of the system time command (systemsetup -gettime) is returned as: Time: HH:MM:SS so I wanted to use awk -F: to grab... (5 Replies)
Discussion started by: xaiu
5 Replies

4. Shell Programming and Scripting

Learning curve to understand bash iteration

Hi Folks, I know on one side there is script and on another side there is smart script. I am able to achieve what I got but thought there has to be a code which doesn't require multiple lines. So if you guys can help me out than it will be awesome. Also I wrote in cshell but if can get both the... (4 Replies)
Discussion started by: dixits
4 Replies

5. Shell Programming and Scripting

Hide bash code which is inside C plus plus program

I am embedding bash in cpp. Can the bash code be hidden (when we cat the executable to not be able to see the bash code) The simple code I am using: #include <iostream> #include <cstdlib> using namespace std; #define test1 "\ #!/bin/sh --posix \n\ echo... (1 Reply)
Discussion started by: frad
1 Replies

6. Shell Programming and Scripting

Aliases NOT working inside bash shell script

i have defined a function ln_s() for customizing the ln command in script1.sh. more script1.sh echo "Starting Execution" ./script2.sh echo "End of Execution" ln_s(){ ] && return ln -s "$1" "$2" } My script1.sh executes another script2.sh which has the following entry more script2.sh... (12 Replies)
Discussion started by: mohtashims
12 Replies

7. Shell Programming and Scripting

Need Multiple checks inside if condition in a bash shell script

Hi, I need to perform the untar and rm operation if the file found is a .tar and does not have test.tar or hello.tar as the file names. Below is the loop to check the same. for tf in *.tar do if ] then found=1 ... (1 Reply)
Discussion started by: mohtashims
1 Replies
XPLOT.ORG(1)						    BSD General Commands Manual 					      XPLOT.ORG(1)

NAME
xplot.org -- fast tool to graph and visualize lots of data SYNOPSIS
xplot.org [-v] [-x] [-y] [-tile] [-mono] [-1] [-d display | -display display] [-d2 display] file [files...] DESCRIPTION
xplot.org is a fast visualization tool for examining multiple data sets in parallel plots. It supports easy zoom-in and zoom-out capabili- ties, and synchronized views into multiple data sets (with the -x, -y, and -tile options). OPTIONS
-1 allows one to look at multiple data sets, one at a time. This changes the behavior of click-right and shift-click-right from exiting and printing to cycling forward and backward through the various plots. -d display, -display display, -d2 display, all select which display(s) on which to draw the graphs. -mono causes the graph(s) to be drawn in black and white, with no use of color. -tile allows one to look at multiple data sets in parallel. The plots will each consume 1/nth of the vertical space that would have been used with one plot. This works well if the window manager refrains from wasting pixels with decorative tabs and respects the hints that xplot.org provides. -v prints the version number. -x causes several graphs to be synchronized on the X-axis (zooming in one window zooms all the others, with the same portion of the X-axis on display). The Y-axis of the other graphs will be autoscaled to fit the data. -y causes several graphs to be synchronized on the Y-axis (zooming in one window zooms all the others, with the same portion of the Y-axis on display). USE OF MOUSE BUTTONS
When running xplot.org, the mouse may be used to zoom in and out on data. Dragging with the left mouse button depressed while inside the axes of the graph draws a rubber-band box around the area to be replotted in the existing window. Dragging with the left mouse button depressed while outside the axes (below the X-axis or to the left of the Y-axis) selects the range of the axis to plot. In effect, this is like the previous mechanism, but only zooming on one axis. Dragging with the middle mouse button inside the axes pans the graph; the start-drag position ends up being at the end-drag position. Drag- ging on the axes pans only in one dimension. Clicking the left mouse button zooms out to the previous view. One can zoom in multiple times, then back up through each view. Panning locations are not saved. Clicking the right mouse button exits the program. Shift-clicking on the mouse buttons produces Postscript files with the same axis extents as the current view. Shift-left produces a full- page view. Shift-middle produces a squarish plot, and shift-right a plot such that three of them fit on a page of LaTeX. PLOT LANGUAGE
There are several example files demo.0, demo.1, demo.2, etc., stored with the xplot.org sources. demo.0 lists all the commands. xplot.org demo.0 demonstrates xplot.org's capabilities. USE WITH TCPDUMP
The command tcpdump -tt -S ... > tcpdump.out saves a tcpdump formatted output trace to tcpdump.out. The -tt and -S flags tell tcpdump to print an unformatted timestamp and to use abso- lute TCP sequence numbers. This trace can then be examined by being processed with tcpdump2xplot. tcpdump -plot tcpdump.out SEE ALSO
tcpdump2xplot(1) tcpdump(8) HISTORY
The xplot.org command was written by Tim Shepard as a tool to use in his analysis of TCP performance while at MIT. Some features were added by Andrew Heybey and Greg Troxel. BUGS
Some people may not like that the right mouse button exits without confirmation, although others consider it a feature that enables rapidly viewing hundreds of similar plots. Should use standard X geometry specifications. BSD
27 January 1999 BSD
All times are GMT -4. The time now is 12:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy