shell

Do people still live by the 80 column rule?

I have recently been converted, at least on the principal that I can read and edit my code as I left it from any terminal in the world. But I still ask myself, when will I ever need to do that? I am finding in c++, especially modern c++, my lines are longer, with more namespace qualified references, etc. So what do people think, 80 colu...

Unix command to find lines common in two files

I'm sure I once found a unix command which could print the common lines from two or more files, does anyone know its name? It was much simpler than diff. ...

Why is "echo foo | read a ; echo $a" not working as expected?

I could replicate the problem with various shells under FreeBSD, GNU/Linux, and Solaris. It had me head-scratching for more than an hour, so I decided to post the question here. ...

Convert decimal to hexadecimal in UNIX shell script

In a UNIX shell script, what can I use to convert decimal numbers into hexadecimal? I thought od would do the trick, but it's not realizing I'm feeding it ASCII representations of numbers. printf? Gross! Using it for now, but what else is available? :) ...

IDE that provide autocompletion and error detection for Linux bash or shell scripting?

Our dev team is looking for an IDE like vi or nano or even textpad for windows that has the capability to autocomplete and error correction for bash or shell script for linux. Basically something similar to .NET autocompletion where you will be able to see if an if[ $# -ne 5 ]; then has no space between the 5 and the ] will tell yo...

Integrate with the Windows Shell

OK, I want to create a windows shell extention that sits in the file menu much like the "Tortorise SVN" menu. Does anyone know where I'd begin, a good article, or what interfaces to implement? Thanks! ...

Get specific lines from a text file

I am working on a UNIX box, and trying to run an application, which gives some debug logs to the standard output. I have redirected this output to a log file, but now wish to get the lines where the error is being shown. My problem here is that a simple cat output.log | grep FAIL does not help out. As this shows only the lines which ...

Are there good reasons not to exploit '#!/bin/make -f' at the top of a makefile to give an executable makefile?

Mostly for my amusement, I created a makefile in my $HOME/bin directory called rebuild.mk, and made it executable, and the first lines of the file read: #!/bin/make -f # # Comments on what the makefile is for ... all: ${SCRIPTS} ${LINKS} ... ... I can now type: rebuild.mk and this causes make to execute. What are the reasons fo...

NSTask not picking up $PATH from the user's environment

I don't know why this method returns a blank string: - (NSString *)installedGitLocation { NSString *launchPath = @"/usr/bin/which"; // Set up the task NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:launchPath]; NSArray *args = [NSArray arrayWithObject:@"git"]; [task setArguments:args]; // Set the...

How can I non-recursively migrate directories with Perl or shell?

Hello, We're migrating home folders to a new filesystem, and I am looking for a way to automate it using Perl or a shell script. I don't have much choice in programming languages as the systems are proprietary storage clusters that should remain as unchanged as possible. Task: Under directory /home/ I have various users' home folders a...

How do I add a button to Vista's Explorer green toolbar for all folders?

I'm looking for a way to add commands to the green Vista toolbar/commandbar, much like described in this Shell Revealed article. However, the IExplorerCommandProvider interface that they use only seems to be active when used in a Namespace Extension. I need something that will work system-wide, for all folders. Does vista expose anything...

How can I process a list of files that includes spaces in its names in Unix?

I'm trying to list the files in a directory and do something to them in the Mac OS X prompt. It should go like this: for f in $(ls -1); do echo $f; done If I have files without spaces in their names (fileA.txt, fileB.txt), the echo works fine. If the files include spaces in their names ("file A.txt", "file B.txt"), I get 4 strings (fil...

Creating a testing environment with php cli

I would use php in console mode and create an environment to test directly my functions. In fact i would not be force to use a web browser and create a new file each time i want to test a function. I want to get in input the function in the console and then it return the result. So can someone if it is possible and how do i do? ...

Programmatically tell difference between git-svn and git repos?

I've got some shell stuff set up that dynamically defines aliases depending on what sort of VC repo the CWD contains -- so, for example, 'd' runs 'svn diff' or 'git diff', depending. (Based on this blog post, if anybody is interested...) I'd like to define some aliases differently depending on whether I'm in a git repo versus a git-svn ...

Shell script to compare dates from multiple files in Linux

I have lots of home directories under /ifshome on Linux. I want to see which users have not logged in for the past 6 months, and my solution is to parse the /ifshome/user/.lastlogin file. Each .lastlogin file has the same format, 1 line: Last Login: Fri Mar 09 18:06:27 PST 2001 I need to build a shell script that can parse the .lastlo...

How to restrict SSH users to a predefined set of commands after login?

This is a idea for a security. Our employees shall have access to some commands on a linux server but not all. They shall e.g. have the possibility to access a log file (less logfile) or start different commands (shutdown.sh / run.sh). Background information: All employees access the server with the same user name: Our product runs wit...

Compare integer in bash, unary operator expected

The following code gives [: -ge: unary operator expected when i=0 if [ $i -ge 2 ] then #some code fi why? ...

Renaming the trash command of trash-cli?

Hi, I'm the developer of the trash-cli project. The trash-cli project is a opensource implementation of the FreeDesktop.org Trash Specification that provides a command line interface to manage the trashcan. Ideally trash-cli provides these commands: trash (trashes files and directories) trash-empty (empty the trash...

What are the most often linux (power) commands that you use?

To find files containing a particular string, I use this often find . -name * | xargs grep -iH "string" ...

Why is 'cp' failing in this shell script?

Here's a snippet of code from a shell script I have written: for src in $(find . -type f -maxdepth 1 \! -name ${deploy} \! -name gvimrc) do src=$(basename ${src}) dest="~/.${src}" copy="${src} -> ${dest}" cp $src $dest && echo -e "${ok} ${copy}" || echo -e "${fail} ${copy}" done For some reason, cp fails to execute. Fo...