Sponsored Content
Top Forums Shell Programming and Scripting how to find the value of a variable in zsh? Post 302523856 by cmp260 on Friday 20th of May 2011 03:53:51 AM
Old 05-20-2011
zsh scripting, please help me learn

I know this is a but brassy but could someone comment this so I can learn what is going on? It has some comment but not enough for me to understand. the script(s) operate on a series of directories named as a singlle date, eachdirectory contains a file logfile.txt containing timestamped data
many thanks

its actually 2 seperate scripts, the first one feeds data to the second one:
(in zsh for DOS)
first script
Code:
# because windows CMD doesn't actually expand * into arguments for you
exec ./zsh.exe batmon.zsh 20[0-9][0-9]-* > events.txt 2> stats.txt


2nd script

Code:
#!/bin/zsh

# Loop over all commandline parameters 2011-*
# basename strips path just leaving name of file
while [ "$#" -gt 0 ]
do
        DAY=$(./basename.exe "$1" )
        DAY="${DAY[0,4]},${DAY[6,7]},${DAY[9,10]}"

    # The datafiles contain \r, which must be stripped somehow
        while read LINE
    do
        # Convert HH:MM:SS into HH,MM,SS to make awk easier
                TIME="${LINE[5,12]}"
                TIME="${TIME[0,2]},${TIME[4,5]},${TIME[7,8]}"
                echo -e "${DAY},${LINE[0,2]},${TIME},${LINE[14,99]}\r"
    done < "$1/LogFile.txt"
    shift
done > output.txt
./gawk.exe -F "," -f batmon.awk < output.txt


Last edited by Franklin52; 05-20-2011 at 11:28 AM.. Reason: Please use code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tutorials about zsh

hi there I'm looking for tutorials about zsh (beginners to experts) can you give me addresses please? thx a lot (3 Replies)
Discussion started by: SpY974
3 Replies

2. UNIX for Dummies Questions & Answers

Z-shell (zsh)

Z-shell (zsh) anyone use it and how do ya like it? (1 Reply)
Discussion started by: Bodhi
1 Replies

3. UNIX for Dummies Questions & Answers

question about zsh

hi, In bash, $ bind -P | grep yank-last yank-last-arg can be found on "\M-.", "\M-_". this allows me to press ALT key and the period (.) to yank the last argument of the previous command line into the current command line. How can I get the same behavior in zsh ? Thanks ... (0 Replies)
Discussion started by: Andrewkl
0 Replies

4. Shell Programming and Scripting

Using zsh

Hi all i am forced to use tcsh at work but i want to use zsh, so i have added this to my .cshrc if (! $?STARTTCSH) then if ("$tty" != "" && -x /bin/zsh) exec /bin/zsh exit endif but this now stopped me going back to tcsh if i need to, is there a way to do this, i would... (7 Replies)
Discussion started by: ab52
7 Replies

5. Shell Programming and Scripting

zsh and host completion

Hi there is there a way i can add to my .zshrc so that when i type rsh <tab> it takes the name for a list of hosts i know it looks in .ssh/know_hosts but i want it for rsh and for a list that i supply thanks A (4 Replies)
Discussion started by: ab52
4 Replies

6. Shell Programming and Scripting

zsh, prompt, variable expansion, ANSI color sequences

Hi! I am using latest ZSH and I have setopt prompt_subst I have a global hash array variable which contains some color definitions with color names as keys and 256-color ANSI codes (with %{ and %}) as values, eg %{\ePS1="$FG Hello World (%M) > " or PS1=$'$FG Hello World (%M) > ' then it... (3 Replies)
Discussion started by: galanom
3 Replies

7. UNIX for Dummies Questions & Answers

ZSH Colors on AIX7

I'd put together a zshrc for use on Linux & AIX 5/6 at another shop that worked fine, but when I tried to put it on here it messes up the colors for some reason I can't understand. I used Phil's ZSH prompt for starters, and everything worked before, and still does on Linux, but isn't working on... (0 Replies)
Discussion started by: Vryali
0 Replies

8. Shell Programming and Scripting

Can I do this without eval? (zsh)

I have in one shell variable, op, a string which represents a "test operator" in a ] construct, for instance -d or -n or -s, an in another shell variable, arg, some arbitrary string. What I want to achieve, is basically this: #This is INCORRECT code. I just want to get you the idea, what I'm... (7 Replies)
Discussion started by: rovf
7 Replies

9. Shell Programming and Scripting

Zsh array -a vs. -A question

Inside a zsh function, I create a local array with local -a arrayname and a local associative array with local -A arrayname. I also can create an array using set, like this: set -A arrayname value1 value2 value3In this form, I can not explicitly declare that an array is associative or... (2 Replies)
Discussion started by: rovf
2 Replies
fizsh(1)							       fizsh								  fizsh(1)

NAME
fizsh - friendly interactive zshell. SYNOPSIS
fizsh [OPTIONS]... [ARGUMENTS]... DESCRIPTION
Fizsh is a front end to zsh. Fizsh provides zsh with interactive syntax-highlighting and a MATLAB-like history-search. Fizsh is intended to look and feel similar to fish. A distinguishing feature is that fizsh can handle Bourne compatible syntax. This is because fizsh is a front end to zsh. Fish uses its own syntax. CONFIGURATION
$HOME/.fizsh is the directory where fizsh keeps its configuration files. The file $HOME/.fizsh/.fizshrc serves as the user's local startup script. Local customizations, such as aliases and functions, can be added here. $HOME/.fizsh/.fizshrc allows the same syntax as $HOME/.zshrc under zsh. $HOME/.fizsh/.fizsh_history is default name of fizsh's history file. The other files in $HOME/.fizsh are installed by /usr/bin/fizsh. In order to reinstall these files use: /usr/bin/fizsh -r or /usr/bin/fizsh --reinstall. Compared to the default configuration of zsh, fizsh additionally sets the options "histignorealldups", "histignorespace", "histreduceblanks", "incappendhistory", "interactivecomments", "promptsubst", "correct" and "nobeep". For further configuration details consult zsh's man pages. INVOCATION
Fizsh is meant to be invoked without options and without command-line arguments. The only supported command-line options are "--version", "--help", "--login", "--reinstall", "-v", "-h", "-l" and "-r". "--version" or "-v" yields fizsh's version number. "--help" or "-h" causes fizsh to print brief usage information. "--login" or "-l" cause fizsh to be a login shell. "--reinstall" or "-r" will reinstall some of fizsh's configuration files (see above). If invoked with other command-line options and/or arguments fizsh will silently revert to zsh. BUGS
There are no known bugs at the moment. Bug reports, bug fixes and other comments are welcome. NOTES
MATLAB is a registered trademark of The MathWorks, Inc. AUTHOR
Written by Guido van Steen, based on work by the "zsh-syntax-highlighting contributors" and the contributors to "zsh-history-substring- search". SEE ALSO
zsh(1) fish(1) Version 1.0.2 9 Aug 2011 fizsh(1)
All times are GMT -4. The time now is 04:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy