Berkeley CSUA MOTD:Entry 33042
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2017/11/18 [General] UID:1000 Activity:popular
11/18   

2004/8/20-21 [Computer/SW/Unix] UID:33042 Activity:moderate
8/20    How do I make tcsh to return an empty list for things like
        foreach foo (bar/*) if there is no glob match rather than
        generating an exception and stops the script?
        \_ the "nonomatch" variable doesn't quite do what you want,
           but it's pretty close.
           \-sigh, this is one of those lame things about csh.
             you can do foreach i (`echo bar/*`) which will generate
             an error, but the foreach will work. you can of course
             do foreach i (`echo bar/* >&/dev/null`) to not see the
             error. but in both of these cases, the loop will not run
             even once. if you want to run the loop once with empty
             args, you would need to foreach i (`echo bar/* >&/dev/null` " ")
             [or something like that]. of course you can replace echo with
             find bar -type f etc. you may be better off building the
             filelist with find, then doing an if -z and then calling
             the loop. otherwise you get weird behavior ...
             set foo = "" then try ls $foo, ls "$foo", touch $foo, touch "$foo"
             and then try with set foo = " ". you either have to be really
             conservative in your quoting and such or you have to check
             inputs ... it's actually pretty much impossible to be fully
             conservative in csh to deal with arbitrary valid filenames
             [!, space, tab, $, %, ? , * are all legit filechars].
             this is a big pain in the ass on osX.
             --mr. tcsh
             \_ Yes, this is what perl is for.  --other tcsh guy
                \- well i think tcsh is fine for a lot of one shot things
                   and maybe if you "know" it will be well behaved. --psb
2017/11/18 [General] UID:1000 Activity:popular
11/18   

You may also be interested in these entries...
2009/8/18-9/1 [Computer/SW/Unix] UID:53284 Activity:nil
8/18    Is it possible to truncate your path name in your prompt in tcsh?
        Tsch veterans REPRESENT!  I know this is how to do it in bash:
        # truncate path: returns $1 truncated to $2 chars, prefixed with ...
        truncate_path () {
                if [ -z "$1" -o -z "$2" ]
                then
	...
2009/8/19-9/1 [Computer/SW/Unix] UID:53285 Activity:nil
8/18    Hi again, new freebsd guy here again, in bash I was able to go
        LD_LIBRARY_PATH=/opt/foo/lib ./runmyapp
        I managed to do this in tcsh by using setenv in a shell script
        that setenv's the lib path and then executes $1, just wondering
        if there was a way to do it in 1 line from the cmd line as in bash?
        Thanks, btw %2c or %3c worked.  Freebsd, tcsh and vi forever!
	...
2009/1/20-26 [Computer/SW/Unix] UID:52420 Activity:low
1/20    I have a rather common shell-scripting problem, but I am not sure
        how to do it in csh/tcsh.  I want to check the ctime (last
        modified time) of a file.  If it is older than, let say, 1
        hours, do something, older than 3 hours, then do something +
        something else.  Any hints on how to do this?  do i need to
        convert it to epoch to perform such manipulation?  thanks
	...
2009/1/20-26 [Computer/SW/Languages/Java, Computer/SW/Languages/Misc] UID:52425 Activity:nil
1/20    I've been using tcsh as shell program tool (i know, bad shell to
        do scripting).  One thing I've noticed when I extract xml file
        is that the variable type automatically change from
        integer/string to... almost an array-like data structure when
        the output of the xml key/value is more than one (it's more
        like a string separated by space, but I was very impressed as
	...
2009/1/13-22 [Computer/Theory] UID:52367 Activity:kinda low
1/13    I am writing a commandline parser for a class and I could use some
        tips for algorithms to use. (The project is over and done so I am
        not cheating, but I am dissatisfied with my end result.) I STFW and
        didn't come up with too much I liked. I read the source for some
        shells like tcsh and that is *WAY* too complicated and relies on
        a lot of other code. I know that browsers and other apps have
	...
2007/10/9-11 [Computer/SW/Unix] UID:48269 Activity:nil
10/9    It's great that soda's been more or less up for the past few months,
        but I really hate Linux and all this gnu shit... ELinks, crappy vi,
        etc.  I miss links and a tcsh that works.
        \_ What's wrong with the current tcsh on soda?  Why don't you just ask
           root to install links or build it yourself?  Also, barring things
           that actually need to talk to the kernel, e.g. threading libraries,
	...
2006/10/30-11/1 [Computer/SW/Unix] UID:45041 Activity:high
10/30   My favorite command in UNIX is "cal". What is your favorite?
           \_ Nein, I vill be. A German and a Jerry, danke, und Heil! -John
              \_ PARSE ERROR. Are you on drugs again John?
                 \_ That's just my troll farm being rambunctious.  Use new
                    Extra Strength Troll-Gro for healthy and frisky trolls!
        \_ Based on frequency of use, gonna have to go with tcsh
	...
2006/9/1-3 [Computer/Networking, Computer/HW] UID:44235 Activity:nil
9/1     I want to add a quick and dirty alias for a server on my local machine.
        So instead of using some-really-long-host-name, I want to use srlhn:
        scp me@srlhn:foo
        But if I put that into /etc/hosts, it requires an IP address, and this
        server may be changing its IP address from time to time.  I'm not
        running DNS.  Any suggestions?
	...
2006/5/23-28 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:43168 Activity:nil
5/23    I'm trying to learn sh, bash, and csh programming. What's a good
        site that has sample syntax of the following ***psuedocode*** for
        each of the shells?
        foreach $file in (<dir/*>) do;
          echo I have file $file
        done;
	...