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
root_geometry_manager() 												   root_geometry_manager()

Name
  root_geometry_manager - Shell class method called to negotiate shell geometry requests with a window manager.

Synopsis
  typedef XtGeometryResult (*XtGeometryHandler)(Widget, XtWidgetGeometry *,
  XtWidgetGeometry *);
	   Widget w;
	   XtWidgetGeometry *request;
	   XtWidgetGeometry *geometry_return;

Inputs
  w	    Specifies the shell widget making the request.

  request   Specifies the requested geometry.

Outputs
  geometry_return
	    Specifies the reply geometry.

Returns
  The window manager's reply: XtGeometryYes, XtGeometryNo, XtGeometryAlmost, or XtGeometryDone.

Availability
  Release 4 and later.

Description
  The  root_geometry_manager() method is registered on the root_geometry_manager field of a ShellClassExtensionRec structure with record_type
  NULLQUARK, which is itself registered on the extension field of the Shell class part structure.  The root_geometry_manager() method will be
  called  when a shell widget calls XtMakeGeometryRequest() or XtMakeResizeRequest(), and should negotiate the requested size with the window
  manager.

  The arguments to this method are the same as those passed to the geometry_manager() method.  The root_geometry_manager() method should pass
  the  geometry  request on to the window manager.  If the window manager permits the new geometry, the root_geometry_manager() should return
  XtGeometryYes; if the window manager denies the geometry request or it does not change the window geometry  within  some  timeout  interval
  (the	XtNwmTimeout resource for WMShell, for example), the root_geometry_manager() should return XtGeometryNo.  If the window manager makes
  some alternative geometry change, the root_geometry_manager() method may either return XtGeometryNo  and  handle  the  new  geometry	as  a
  resize,  or  may return XtGeometryAlmost in anticipation that the shell will accept the compromise.  If the compromise is not accepted, the
  new size must then be handled as a resize.

  Communication with a window manager is an asynchronous process, but the root_geometry_manager()  procedure  must  return  its  answer  syn-
  chronously.  It will have to issue its request and then block until the reply arrives.

  The  root_geometry_manager()	method is not chained.	It can be inherited by specifying XtInheritRootGeometryManager in the Shell extension
  record.  If there is no Shell extension record with record_type equal to NULLQUARK, then the Intrinsics will behave as if an extension  was
  specified with XtInheritRootGeometryManager.

  See  the Inter-Client Communications Conventions Manual for information on communicating with window managers.  See geometry_manager(4) for
  a description of the structures and the possible return values of this method.

Usage
  The root_geometry_manager() method of the Shell class itself handles communication with  ICCCM-compliant  window  managers.	It  sets  the
  appropriate  properties  to  make the geometry request, then uses XCheckIfEvent() to block until an ConfigureNotify event arrives in reply.
  This method also uses private functions internal to the Intrinsics in order to correctly handle the events.  Because of the complexity  and
  implementation-specific  nature  of  this  method,  classes  that  want to define a custom root_geometry_manager() method should make their
  requests to the window manager, and then call their superclass's method to make additional requests, block, and get the response.

See Also
  XtMakeGeometryRequest(1), XtMakeResizeRequest(1),
  Shell(3),
  geometry_manager(4).

Xt - Intrinsics Methods 												   root_geometry_manager()
All times are GMT -4. The time now is 03:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy