shell

What UNIX commands support coloured output?

I enjoy using UNIX/bash commands that support coloured output. Consequently, I have a few aliases defined which automatically enable coloured output of the commands that I know support this option. However, I'm sure there are hundreds of commands out there that support coloured output - I'd like to know what they are. The ones in my ~...

Zsh tab-completion for "cd .."

How can I configure the Zsh tab-completion such that when I type cd ..<TAB> it expands to cd ../ and after pressing <TAB> again proposes the folders in the parent directory for completion? E.g. it should show the same behavior as when typing for example cd Documents<TAB> which expands to cd Documents/ and after pressing <TAB> again prop...

File association - modify shell's edit verb on Vista

I'm looking to programmatically modify the edit verb for the shell on Vista. For example, I want right click edit (in explorer) to open a .cs file w/ Notepad++. How do I change a file association on Windows Vista? Thanks ...

How do I escape a left paren in a Perl regex?

If I have a file containing some escaped parens, how can I replace all instances with an unescaped paren using Perl? i.e. turn this: .... foo\(bar .... into this .... foo(bar .... I tried the following but receivied this error message: perl -pe "s/\\\(/\(/g" ./file Unmatched ( in regex; marked by <-- HERE in m/\\( <-- HERE / at ...

How can I gzip standard in to a file and also print standard in to standard out?

I want to execute a command, have the output of that command get gzip'd on the fly, and also echo/tee out the output of that command. i.e., something like: echo "hey hey, we're the monkees" | gzip --stdout > my_log.gz Except when the line executes, I want to see this on standard out: hey hey, we're the monkees ...

Bash: How do I check if certain files exist?

In a bash script, I have to check for the existence of several files. I know an awkward way to do it, which is as follows, but that would mean that my main program has to be within that ugly nested structure: if [ -f $FILE1 ] then if [ -f $FILE2 ] then echo OK # MAIN PROGRAM HERE fi fi The following version does not work: ([ -f ...

PowerShell vs. Unix Shells

I'm debating whether I should learn PowerShell, or just stick with Cygwin/Perl Scripts/Unix Shell scripts, etc. The benefit of PowerShell would be that the scripts could be more easily used by teammates that don't have cygwin; however, I don't know if I'd really be writing that many general purpose scripts, or if people would even use t...

How does "while (sleep 100 &!) do; done" work in zsh, and how could it be replicated in bash?

According to wikipedia ( http://en.wikipedia.org/wiki/Fork_bomb ), the forkbomb ":(){ :|:& };:" can be stopped with the zsh command "while (sleep 100 &!) do; done", which will supposedly spawn sleep 100 processes until all the forkbomb processes are gone. This seems like magic to me. Can anybody explain why/how this works? I'm especia...

Windows: How to open a .exe in a shell window that won't close?

I've had this problem for ages, and it's SO ANNOYING. Suppose I want to run mysqldump.exe... here's my process: Start->run, type "cmd" ... dir into directory after directory until I finally get to c:/program files/mysql/bin/then I can FINALLY call "mysqldump.exe" I don't mind using Windows Explorer to get to c:/program files/mysql/bin...

I'd like to scrape the iTunes top X RSS feed and insert into a dB...

Preferably I'd like to do so with some bash shell scripting, maybe some PHP or PERL and a MySQL db. Thoughts? ...

Open a file from Cygwin

Hello, is there an equivalent to OSX open command in cygwin. open opens a file with the default application for that type. I want to do something like $ magic-command file.xls #excel opens as if file.xls would have been double-clicked $ magic-command file.txt #notepad opens as if file.xls would have been double-clicked You get the ...

Shell script datetime function?

I am running the following script: #!/bin/ksh ./clear_old ./rooms_xls.pl 2/23/09 cd doors ./doors_xls.pl 2/23/09 How can I get the date to be today's date based upon the system/server time? ...

linux g++ compiler redirect stderr and stdout creates empty file

I am redirecting the g++ compiler output(both stderr and stdout) to a file on linux. But it is creating an empty file. I read in some other post that stdout is not flushed after every line. Thats ok, but what about stderr. In my case there are compilation errors running several screens. So, I am interested in stderr output. There is no ...

yacc, only applying rule once

Hi guys, I'm trying to write a shell using yacc and lex and I'm running into some problems with my I/O redirectors. Currently, I can use the < and > operators fine and in any order, but my problem is I can redirect twice with no error, such as "ls > log > log2" My rule code is below, can anyone give me some tips on how to fix this? Than...

Check file size in shell and display file and path above a threshold

I am trying to check for files which are larger than a given threshold. I know that the 'du' comand gives me the output for each file/folder, but how to put that in a single line on shell (using awk with if clause?). ...

Getting the path of a ClickOnce File Association

I've using ClickOnce and I'm struggling with file associations. I can set up the association. Double-clicking an associated file even launches the application. ...However... I don't know how to get access to the path of the file clicked to launch the App. Has anyone come across this before? ...

How do you run a command in iTerm when it launches?

I'm working on configuring the iTerm terminal emulator for the Mac to do what I want. Apparently everything is done through what they call "bookmarks." OK, fine. I'm trying to create a bookmark that will open a tab, cd to a certain Rails project, and run the command script/server. What's supposed to happen is that this will launch the se...

Recursively search directories moving specified file type from one location to another preserving directory structure.

Is there some way to specify a directory (let's say "C:\images") and move every .jpg file from there to another directory (say "D:\media") but preserve the directory structure (so if the file were "C:\images\paintball\july\07\headshot.jpg" after moving it would be "D:\media\paintball\july\07\headshot.jpg")? I'm using cygwin (but would b...

How can you untar more than one file at a time?

I have a bunch of tar files in a directory and I want to extract all the files from them at once. But this doesn't seem to do anything: $ tar xf *.tar What's going on here? How do I untar a bunch of files at once? ...

sed scripting - environment variable substitution

Hi all, I have sed related question: If I run these command from a scrip: #my.sh PWD=bla sed 's/xxx/'$PWD'/' ... $ ./my.sh xxx bla Which is fine. But, if i run: #my.sh sed 's/xxx/'$PWD'/' ... $ ./my.sh $ sed: -e expression #1, char 8: Unknown option to `s' I read in tutorials that to substitute env. variables from shell you need...