shell

What is the Powershell analogue of $@ used to call another command?

In a Unix shell script, to call command 'foo' on the original arguments to the script, you just write foo $@ In Powershell, $args is an array of (typically) strings holding the current script's arguments. If you write foo $args will the same thing happen as in bash or other typical Unix shell script interpreters? ...

How to solve a linear system in Linux shell?

Hi, Does anyone know of a Linux command that reads a linear system of equations from its standard input and writes the solution (if exists) in its standard output? I want to do something like this: generate_system | solve_system ...

change random line with shellscript

how can i easily (quick and dirty) change, say 10, random lines of a file with a simple shellscript? i though about abusing ed and generating random commands and line ranges, but i'd like to know if there was a better way ...

Creating a timed launchd plist.

Hello everyone! I'm trying to create a plist for the LaunchAgents folder that will run perpetually and call a shell script every 30 seconds. It started with a template that I got here and that I tried to tailor to fit my needs, but it's still not working. Any help? <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple...

Splitting a binary file on binary delimiter?

I'm working on a shell script to convert MPO stereographic 3D images into standard JPEG images. A MPO file is just two JPEG images, concatenated together. As such, you can split out the JPEG files by finding the byte offset of the second JPEG's magic number header (0xFFD8FFE1). I've done this manually using hexdump/xxd, grep, head, and ...

Bash: echo string that starts with "-"

VAR="-e xyz" echo $VAR This prints "xyz", for some reason. I don't seem to be able to find a way to get a string to start with -e. What is going on here? ...

Shell Script Variable Bug?

Hello generous computerists! So I have a launchd plist item that is calling the below shell script every thirty seconds. It checks to see if a program is running and if it isn't, it restarts it. Or at least that is what it's supposed to do. The problem is, even when the process has been killed, the shell script is stating that the proc...

Shell:How to substitute the field of the text while keeping the same blank space

I want to substitute a certain filed of the text while keeping the same blank space: For example, my text is: Please help me with this problem Any suggestion or help will be appreciated Thanks to all who give help And I want to replace the sentence "Any ...

How to extract info from text file with PHP or maybe a shell script

Hi Guys, I am trying to create my own web interface for the plowshare utility, managed to get the script running okay so far, but I am a bit unsatisfied by the way the results are being displayed. Currently I am loading the text file into an array and display it and refresh the page from time to time to load the new results. The text fi...

How to run R script line by line from linux shell?

I'm used to work on my R scripts with some GUI, so I can easily run commands line-by-line, then pause and inspect my objects as they are created and changed. I currently need to work with some data on a remote server. Is it possible to run line-by-line using R console or some other application (please, not vi) that does not require real...

Debug shell script in IntelliJ 9

Is it possible to debug a shell script in IntelliJ IDEA 9.0.3. I hava a shell script that calls a java program. I would like to set a breakpoint in this java program and debug through it. I hava a Bash plugin for IntelliJ and have set the breakpoint in the program but it doesn't stop at the breakpoint. Thanks, Tom ...

NSTask with bash script problem

For example, i have this simple bash script: #!/bin/sh cd $1; And this cocoa wrapper for it: NSTask *cd = [[NSTask alloc] init]; NSString *testFolder = [NSString stringWithString:@"/Users/test/Desktop/test 1"]; [cd setLaunchPath:@"/bin/sh"]; [cd setArguments:[NSArray arrayWithObjects:[[NSBundle mainBundle] ...

Start Gnome-Application from SSH-Shell

Hello, my development server has a running Gnome-Desktop. I am connected to it by a ssh session. The Gnome-Session and the ssh session are running with the same user. How to I start a Gnome-application (for example gedit) from the ssh remote session so that it appears on the remote servers Gnome-Desktop? Thanks a lot, Hacksteak25 ...

extracting nested different types of archives from different folders

Hi, I have got an archive of many fonts but i have troubble extracting them all into one folder. i tried to write a long script for 3 hours now, it somehow breaks on a path issue. i tried piping like find . -name *.zip|unzip -d ~/fonts but it doesnt work. i changed so much in the script i wrote, that it is not really presentable :(. eac...

Quoting in a bash variable assignment

Using the following simplified code extract: DIR='a b' mount_command="./mount.cpfs $loop $DIR -f $OPTS" sudo $mount_command Executes this line when trace is on: + sudo ./mount.cpfs /dev/loop0 a b -f -o default_permissions,allow_other,attr_timeout=0 But DIR is not quoted, and so a and b are passed as different parameters, rather tha...

"Permission denied" error on .sh script on RHEL5

root@server [/mnt/elm332/Setup/Linux]# ./setupLinux64.sh -c Unpacking JRE ... Starting Installer ... ./setupLinux64.sh: line 433: /tmp/setupLinux64.sh.28603.dir/jre/bin/java: Permission denied root@server [/mnt/elm332/Setup/Linux]# whoami root Why would this be happening? Note that this is a mounted ISO file (copied in /tm...

Is there something like Lint or Perl::Critic for shell scripts?

Are there any shell (specifically bash or ksh) checkers that test shell scripts for style, best practices, naming conventions, etc? (Something like Lint for C, or Perl::Critic for Perl.) I know with ksh you can do syntax checking by running ksh -n script.ksh but I was hoping for something more than just sytax checking - something that ...

C function to escape string for shell command argument?

What function should I use to escape strings for shell command argument in C? I have a string: This is a string with () characters This will be error: echo This is a string with () characters These are OK: echo "This is a string with () characters" echo This is a string with \(\) characters Is there a predefined function convert ...

shell script to capture keyboard activities

How to capture all keyboard strokes using shell script .Is there any command that is related to keyboard activities. ...

linux shell script to add leading zeros to file names

I have a folder with about 1700 files. They are all named like 1.txt or 1497.txt etc. I would like to rename all the files so that all the filenames are 4 digits long. IE 23.txt becomes 0023.txt. What is a shell script that will do this? Or a related question: How do I use grep to only match lines that contain \d.txt (IE 1 digit, t...