You are not logged in.

#1 2008-07-28 09:40:37

patogen
Member
Registered: 2008-05-11
Posts: 86

Simple zsh

I want to know how you most easily do this. Often I find myself doing this command:

for a in PATTERN; do cksfv -i -g $a/*.sfv; done

I would like to make a simple command that I can issue like:

chk PATTERN

and it would run that command. But I'm not sure how. I've stolen a .zshrc and built a function out of it (from the examples in that). But it doesn't work:

function chk {
for a in $1; do cksfv -i -g $1/*.sfv; done
}

And I ussue:

chk PATTERN*

But it will only take the first one in the pattern not all of the patterns. So how would I make something that takes all?

But it only uses the first file.


(the -i flag is to ignore cases and -g is to select a file)


We met up with the aliens and guess what? They have no word for fluffy!

Offline

#2 2008-07-28 09:47:00

eXire
Member
Registered: 2006-08-08
Posts: 15

Re: Simple zsh

use single quotes to prevent shell substitution.
chk 'PATTERN*'

Offline

#3 2008-07-28 12:32:28

patogen
Member
Registered: 2008-05-11
Posts: 86

Re: Simple zsh

eXire wrote:

use single quotes to prevent shell substitution.
chk 'PATTERN*'

Will not work:

chk 'PATTERN*':
chk:1: no matches found: PATTERN*/*.sfv

chk 'PATTERN'
chk:1: no matches found: PATTERN/*.sfv

chk 'PATTERN'*'' will give same as chk PATTERN, it only takes the first


We met up with the aliens and guess what? They have no word for fluffy!

Offline

#4 2008-07-28 12:39:38

eXire
Member
Registered: 2006-08-08
Posts: 15

Re: Simple zsh

You need to update your function:

function chk {
for a in $1; do cksfv -i -g $a/*.sfv; done
}

Offline

#5 2008-07-28 12:44:08

eXire
Member
Registered: 2006-08-08
Posts: 15

Re: Simple zsh

Oh, sorry. I'm a stupid man.

Your function must looks like this:

function chk {
for a in $@; do cksvf -i -g $a/*.sfv; done
}

And you can call it like this (without quotes):
chk PATTERN*

Offline

#6 2008-07-28 13:20:26

patogen
Member
Registered: 2008-05-11
Posts: 86

Re: Simple zsh

eXire: Thank you very much. That solved it!


We met up with the aliens and guess what? They have no word for fluffy!

Offline

Board footer

Powered by FluxBB