shell

Make Arrow and delete keys work in Korn shell Command line

Hi all, I am new to unix and am using sun solaris (v10 i think) . I have my shell set as korn shell . i am wondering how to make the arrow keys and delete key work in the command line . I have done set -o emacs and the backspace works , but not the arrow keys and the delete keys . Also is it possible to set the up and down arrow key to...

How to install third appliacations to iphone(has been jailbreaked) via shell script

Anybody can tell me how to install a third app to iphone? I want to use shell script,but I can't use fork(),Anybody has an idea? ...

Getting $USER inside shell script when running with sudo ?

Hi, How do I get the correct $USER if I run a shell script with sudo ? I run them as postinstall scripts in a Mac install package, where they are being sudo-ed automatically, but I need to do stuff with the username. $HOME is correct, though. The inelegant method would be to extract the name from the home path, but I wonder if there ...

ssh with command....Plus the shell

Hi, I'd like a command that ssh'es into a machine, runs a command (cd or execute a script or su), and then gives me the shell. Passing a command to ssh seems to always exit. Some examples of what I'm looking for: 'ssh me@machine1 "./executeMyScript && cd /developmentDirectory"' and then it gives me my shell back. The reasons I want to...

Using regular expressions in shell script

What is the correct way to parse a string using regular expressions in a linux shell script? I wrote the following script to print my SO rep on the console using curl and sed (not solely because I'm rep-crazy - I'm trying to learn some shell scripting and regex before switching to linux). json=$(curl -s http://stackoverflow.com/users/fl...

Bash command to open largest file

I feel like this should be simple, but can't figure it out: What's the bash command(s) to look through a folder and open the largest file using VIM? ...

Eclipse Command Line Plugin

I need an Eclipse Plugin run Shell Scripts under Linux. I have a beautiful Rsync Script and i want a Button in Eclipse to activate it. The best Solution would be if the rsync Shell Script was also activated when i was saving Stuff, so maybe i can add a Script Builder or something like that. Anyone has a clue for both of the Solutions? ...

Invoke a CakePHP console shell on server without command line access

Is there way to invoke a CakePHP console shell on server without shell access? I have written a shell for performing some once off (and hence not a cron task) post DB upgrade tasks. I could always just copy the logic into a temporary controller, call its actions via http and then delete it, but was wondering if there was a better way to...

linux shell date question

shell>/bin/date -d "091029 20:18:02" +%s 1256827682 Similarly I created shell script: #My.sh myDate=`date +'%y%m%d_%H%M%S'` myDate1=`echo $myDate | sed 's/_/ /g'` myDate2=`echo $myDate1 | sed 's/\([0-9][0-9][0-9][0-9][0-9][0-9]\) \([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/\/bin\/date -d "\1 \2:\3:\4" +%s/'` print $myDate2 `$myDate2` ...

Deleting smaller sized dupes of files

I'm trying to locate files with the same name and delete all of the smaller sized copies, leaving only the largest. For example: test.jpg = 2kb, test.jpg=9kb, test.jpg=5kb. The 2kb and 5kb files would get deleted, leaving just the 9kb. I've tried a couple of GUI programs to do this and they were no help, as you had to delete everything m...

KShell background task not showing in jobs

I've written a simple KShell script to kick off a background task #/bin/ksh #startMonitoring ./detectFile /usr/local/data/testFile > fileHistory & I run it with the following command startMonitoring When I run jobs I get no results, but the command is running and shows up in ps: 512232 pts/0 0:34 /bin/ksh ./detectFile /usr/...

BASH: Copy named files recursively, preserving folder structure

I was hoping: cp -R src/prog.js images/icon.jpg /tmp/package would yield a symmetrical structure in the destination dir: /tmp | +-- package | +-- src | | | +-- prog.js | +-- images | +-- icon.jpg but instead, both of the files are copied into /tmp/package. A flat copy. (This is on OSX). ...

Is there a grep or shell script that uses a regex to change filenames?

How can I recursively change xxx-xxx_[a-zA-Z]+_\d+_(\d+)\.jpg into $1.jpg? ...

foreach no match -C shell script

I’m trying to write my first script to search for a given pattern in text file named test. Here is the script: #! /bin/csh echo -n "enter pattern: " set pattern = $< foreach word (`cat test`) echo $word | egrep $pattern end When I try to run it I get the message foreach: No match found. I suspect the problem is ca...

Script to count words matching pattern C shell

I wrote this script which counts occurrences of particular pattern in a given file. However if text file contains square brackets or curly braces shell outputs a message "Missing }". Here is the script: #!/bin/csh @ count=0 foreach word ( `cat test` ) if (`echo $word | egrep -c 'int'`) then @ count= $count + 1 endif ...

getting previously typed commands in python

I'm using python 2.5 in windows on a macbook pro with IDLE. How do I get previously typed commands in the python shell? In other operating systems I've managed to do this using 'ctrl' + 'up arrow' or a similar combination. I've tried all likely combinations without success. Thanks. ...

Print execution time of a shell command

Is is possible to print the execution time of a shell command with following combination? root@hostname:~# "command to execute" && echo "execution time" ...

Regular expression Unix shell script

I need to filter all lines with words starting with a letter followed by zero or more letters or numbers, but no special characters (basically names which could be used for c++ variable). egrep '^[a-zA-Z][a-zA-Z0-9]*' This works fine for words such as "a", "ab10", but it also includes words like "b.b". I understand that * at the end ...

How can I display rsync progress from a log file without the carriage returns?

I have a log file from rsync command with progress on. When running this progress updates the display information on the same line. When I capture the output from this command I get a file that displays normally with cat on a terminal (all the backspaces and re-edits are replayed) but I want to be able to use grep on the file and proc...

Comparing strings for equality in ksh

Hello, i am testing with the shell script below: #!/bin/ksh -x instance=`echo $1 | cut -d= -f2` if [ $instance == "ALL" ] then echo "strings matched \n" fi It's giving this error in the if condition: : ==: unknown test operator is == really not the correct syntax to use? I am running on the command line as below test_lsn_2 INST...