shell

How does bash parameter expansion work?

I'm trying to understand a bash script with help of google :) Then I stumbled upon this: DIR=${1:-"/tmp"} What does that mean? Google does not give any relevant result :( ...

removing trailing whitespace for all files in ediff-trees session

Hi, I am using the very handy ediff-trees.el http://www.emacswiki.org/emacs/ediff-trees.el to compare two versions of a pile of Python code provided by one of my project partners. Unfortunately, these guys are checkin in code with trailing whitespace (extra tabs here and there...) which is creating a ton of false positive diffs, whic...

Is there a command that can be run from a cygwin shell to print out an xml file with color highlighting?

Is there a command that can be run from a cygwin shell to print out an xml file with color highlighting? ...

django, python: reload function in shell

Hello, I work in the django IPython-shell, which can be started with manage.py shell. When i load an extern function in the shell for testing, everything is alright. But when i make changes to the function, the shell still has the old version of the function. Even if i make a new import. Does anyone know how to reload the actual versio...

unix utility that reads files into memory?

I am using Ruby's net-ssh library to remotely execute shell commands. I would like to read a few files into memory rather than simply transfer them via SCP/SFTP. Can can I do this? ...

How can you redirect a script's output through a process?

I want to redirect a bash script's output through a logging program. Specifically, Apache's logrotate utility. The redirection needs to be set within the script itself. If the redirection were done on the command line, while executing the script, it would look like this: myscript | logrotate -l $LOGFILE.%F 86400 2>&1 Here is some pse...

How to delay a shell command in delphi?

Hi all I am working with Delphi 2010 and the ShellAPI. I need a little help as the program I am building grows. Here is the jest of the application: Checks to see if a certain condition exists If said condition exists it begins to execute 2 shell commands which are dependent on the previous one executing uses ShellApi; procedure...

Trouble nesting expressions in UNIX.

I have the following UNIX statement: #!/bin/bash $x=$((grep ^'[a-z]' $1 | wc -l)) echo "$x" However, I'm getting an error message relating to a missing operand whenever I try to run the script. Is there any way to assign a variable a value like so in UNIX? EDIT: Well, it became clear to me that grep cannot seem to examine single wor...

Opening an explorer window with designated file selected

Hi Guys, I have an application which has an option to show the selected selected file in the folder in which the file resides. My question is, how do I achieve this? To clarify, if a user in my program selected the "Test.txt" file, then I want a Windows Explorer window to pop up and highlight the file the user selected. You can see sim...

Unix Sed to get lines from a last occurance of a given word

I want to get the lines from a file from the line which contains the last occurance of a given word. Ex: True, there have been some changes in the plot. In the original, Kane tried to buy high political office for himself. In the new version, he just puts politicians on his payroll. If I give "In" then I need offic...

Environment variables in symbolic links

Can we use $HOME or other environment variable in symbolic links? I know about using relative paths ../../.config but sometimes are to many ../ :) something like ~/.config would be more comfortable, or use of $HOME. Edit: habbie's answer with psmears's comment is the answer, sorry my question was incomplete. While (as other answers ...

Can I call one CakePHP shell from another?

I have a CakePHP shell program called 'match', which runs through my database performing some fairly complicated stuff. I'm writing another shell so I can do some proof-of-concept simulation, this shell is called 'simulate'. I need 'simulate' to be able to call 'match', then continue running. As the simulation will repeat many differe...

Using shell script to insert data into remote MYSQL database

I've been trying to get a shell(bash) script to insert a row into a REMOTE database, but i've been having some trouble :( The script is meant to upload a file to a server, get a URL,HASH, and a filesize, connect to a remote mysql database, and insert the data into an existing table. I've gotten it working until the remote MYSQL database...

Can I get GNU Emacs to TAB complete filenames after using ssh in the *shell* buffer?

I am using GNU Emacs 23.1.50.1 (i486-pc-linux-gnu). What I want is conceptually simple, [TAB] indicates that I press the TAB key. M-x shell erik@furby:~$ ls bin Desktop Documents Dropbox R.tools erik@furby:~$ cd Drop[TAB] and tab completion works fine (i.e., Dropbox is completed) However, as soon as I ssh, this no longer wo...

What does '-a' do in Unix Shell scripting

What does -a mean in the below line. if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ] ...

Pass variables from htaccess to bash script

Hi, I'm trying to pass the value of a cookie to a bash script: RewriteCond %{HTTP_COOKIE} mycookie=(.*) [NC] RewriteRule .* script.sh?cookievar=%1 ... but can't seem to find out how to read the GET variable in the bash script. (I suppose I'm asking Google the wrong queries, but can't find any info on this). Is this even possible, an...

python subprocess with shell=True: redirections and platform-independent subprocess killing

Hi, I'm having a hard time getting what I want out of the python subprocess module (which supposed to an unified/platform-independent abstraction, afaik, but don't get me started on that :)). So the simple thing what I'm after is the following. I want to Launch an external (stdio) application (possibly with subprocess), where I use s...

TERM environment variable not set on mac

I keep on getting the "TERM environment variable not set." error when I work with svn commands on my Mac terminal. I thought I had set up my profile by doing: export SVN_EDITOR=/usr/bin/nano export EDITOR=/usr/bin/nano in .profile and .bash_profile, reset the terminal and it still gives me that error. Any help? ...

Unix - Nested Loop. One loop to untar then another to inspect each file in directory

I'm trying to loop round a load of tar files and then move the extracted files into a new folder, inspect them and delete them before moving onto the next tar. Code is below: for i in * do tar -zxvf $i mv *TTF* encoded cd encoded for j in * do echo $j done rm -f *TTF* cd .. done When it gets to the nested loop, ...

Running Pine/Alpine within a windows powershell

Hi, I am attempting to move most of my daily working life to a terminal shell. I am a .NET dev so I run on WinXP purely for visual studio (just wait until I get better at emacs). I would really much like it if I could use an email client within a terminal (either using Console or powershell within Console). From my uni days I know of ...