shell

Simple Shell Scripting Question

Hi, I am a newbie with shell scripting but just wanna quickly do something really simple. I have a testprogram that writes some results into a file "result". I wanna run the program three times and then store the results in an appropriate file with the name result1, result2, etc. I thought something along those lines will do the trick...

Is it possible to cout to terminal while redirecting cout to outfile?

I'm running a program and redirecting cout to an outfile, like so: ./program < infile.in > outfile.o I want to be able to read in an option ('-h' or '--help') from the command line and output a help message to the terminal. Is there a way I can do this but still have the regular cout from the rest of the program go to the outfile?...

bash shell scripting combining *.txt into one file

What is the quickest and most pragmatic way to combine all *.txt file in a directory into one large text file? Currently I'm using windows with cygwin so I have access to BASH. Windows shell command would be nice too but I doubt there is one. ...

Set Screen.WorkingArea.Width?

Sorry if this is a fundamental question and I'm just stupid :) I am building a sidebar application, it uses System.Windows.Forms.Screen.PrimaryScreen.WorkingArea to set the appropriate widths and heights and locations. I want to now reduce the working area of the desktop so that when forms maximise, the sidebar is still shown (in the ...

Viewing full output of PS command

Hi, when I run ps -aux command on my linux server, to which I connected using putty, few processes are too long to fit in my current window width. Is there an alternative? Thank you -- Update -- I am sorry for downgrading,I thought others won't find the answer useful too, so I downgraded. Here is the info you asked for. hadoop-use...

What is the general syntax of a Unix shell command?

In particular, why is that sometimes the options to some commands are preceded by a + sign and sometimes by a - sign? for example: sort -f sort -nr sort +4n sort +3nr ...

imports while starting an interactive shell

When I start the interactive django shell through manage.py, by executing python -v manage.py shell from the project directory, I see a lot of modules of format django.package.module getting imported in the verbose output but still I have to import them to use it in the shell. The same happens when I just run the Python shell (with...

Is there a way to make a shell become interactive in the middle of a script?

I'd like to do something like: do lots of stuff to prepare a good environement become_interactive #wait for Ctrl-D automatically clean up Is it possible with bash? If not, do you see another way of doing the same thing? ...

Give the mount point of a path

The following, very non-robust shell code will give the mount point of $path: (for i in $(df|cut -c 63-99); do case $path in $i*) echo $i;; esac; done) | tail -n 1 Is there a better way to do this? Postscript This script is really awful, but has the redeeming quality that it Works On My Systems. Note that several mount points may...

Best output format for Xargs

I'm writing a simple program to run through a bunch of files in various directories on my system. It basically involves opening them up and checking for valid XML. One of the options of this program is to list bad xml files. This leads me to my question. What the best output to format this for use with XARGS. I thought putting each ...

rearrange column's elements and display count

Hi , i have text file like this: i am fine how are you what i how are i need an output like below: i : 2 am : 1 fine : 1 how : 2 are : 2 you : 1 what : 1 there can be many repititions of the words: how could i do this using a shell script or an awk? ...

Webapp update shell script

I feel silly asking this... I am not an expert on shell scripting, but I am finally in enough of a sysadmin role that I want to do this correctly. I have a production server that hosts a webapp. Here is my routine. 1 - ssh to server 2 - cd django_src/django_apps/team_proj 3 - svn update 4 - sudo /etc/init.d/apache2 restart 5 - logout ...

How can i grep a nearer word from a file ?

How can i grep a nearer word from a file ? E.g 04-02-2010 Workingday 05-02-2010 Workingday 06-02-2010 Workingday 07-02-2010 Holiday 08-02-2010 Workingday 09-02-2010 Workingday I stored above data in a file 'feb2010', By this commend i stored date in one variable date=date '+%d-%m-%Y' if date is 06-02-2010 , i want to grep " 0...

How to use IFolderView?

How to use IFolderView? How Can I know the icon position and order of a certain Folder in Explorer? Many Thanks! ...

Un*x shell script: what is the correct way to run a script for at most x milliseconds?

I'm not a scripting expert and I was wondering what was an acceptable way to run a script for at most x milliseconds (and yet finish before x milliseconds if the script is done before the timeout). I solved that problem using Bash in a way that I think is very hacky and I wonder if there's a better way to do it. Basically I've got on...

How to change the prompt in putty

Hi when i start putty on a server i get the promp like below: hpbl802!benjaminb:~ [22]> How can i change this prompt to benjamin:~ [22]> ...

Run cronjob as user to change desktop background in Ubuntu

I am trying to run this script which changes my desktops background to a random picture in a directory. It works from the command line, and the cronjob gets run (added output and it gets spit out to a log file), but I can't get it to change my background. Here's my current line (set to run every minute for testing). 01 * * * * username ...

shell script running by sensing a file

Hi, i am working on unix. i want to write a shell script which will check for a file called "temp_file.txt" on windows and then execute some commands. is this possible? how could we connect to the windows and go to a specific directory and check for a file? ...

What is the korn typset option -t (tag) used for?

I was reading about the Korn typeset command and discovered the -t option adds a tag, but I can't figure out what it's used for. Does anyone have an example? -t Tags the name. Tags are user definable and have no special meaning to the shell. ...

On LINUX O.S., how to get the name of files that has been dropped onto shell script to boot JAR with the name of file as a argument to JAR

I have a shell script file to run jar on Linux O.S which contains #!/bin/sh #MyApplication MyApplication_home='/Desktop/MyApplication' chkpath="$MyApplication_home/jre6/bin/java" if [ -e $chkpath ] then export PATH=$MyApplication_home/jre6/bin:${PATH} export CLASSPATH=$MyApplication_home/MyJar.jar:${CLASSPATH} java -Xmx512M -jar MyJar.j...