shell-scripting

shell scripting arithmetic operations

in general i will use expr inside shell scripts for doing arithmetic operations. is there a way where we can come up with arithmetic operation in a shell script without using expr? ...

Shell script to copy files

If there exist a directory, /backup/ And the files in it are a.gz b.gz c.gz And another directory /backup-directorybackup And the files in it are a.gz I need a shells script to compare two directories if the files are present then ignore it and if the filesare not present copy it to the destination directory Thanks.. ...

Enter a letter when prompted by another command

Hi all, I'm trying to automate the installation and deployement of an application. To do it, i have a shell script with the following instructions: /usr/local/bin/amf install -u $1 -p $2 $localTarget where $1, $2 and $localTarget are options for the command named 'amf'. The problem is that the 'amf' command make severall instructio...

configuration file editor in Eclipse

Greetings, Anybody uses Eclipse to edit configuration files like httpd.conf and the likes, or even shell scripts? Which editors are there for that? Thanks. Pedro. ...

Sed not working inside bash script

Hello. I believe this may be a simple question, but I've looked everywhere and tried some workarounds, but I still haven't solved the problem. Problem description: I have to replace a character inside a file and I can do it easily using the command line: sed -e 's/pattern1/pattern2/g' full_path_to_file/file But when I use the same l...

How do you read a csv file into a two dimensional array in BASH?

How do you read a csv file into a two dimensional array in BASH? The script needs to be dynamic enough where it can take csv files with variable number of rows and columns. For example, if I have a csv file that looks like AVERAGE STDEV MAX 17 18 19 or AVERAGE STDEV MAX MIN 17 18 ...

ps forrest for session id

Often I want to get a nice readout what process are running and their relationship; I usually by habit runs ps auxfww and eventual grep for the process in question. Having been thinking about the problem I tried to create an oneliner to get the process tree in ps ufww format for all processes which has the session id specified by arbitr...

How to get Command history by cursor key in Linux tclsh : TCL

I am new to TCL and I wanted to know, if I can get the command history by using cursor key (like up arrow key) in TCL shell (tclsh). I am running tclsh on fedora with linux version 2.6.21. ...

Cut a file based on a text marker

I have a text file that has the following layout: text text .. CUT HERE text text .. The literal CUT HERE appears only once. What I want to do using shell scripting, is to produce another file containing all the text below CUT HERE, i.e. ignore whatever above CUT HERE. Thanks. ...

Auto completion by typing TAB in TCL

hi all, How can I achieve auto-completion of key words and directories by typing TAB (or something else) in TCL shell , tclsh. Thanks in advance aditya ...

Regarding grep in solaris

I want grep for a particular work in multiple files. Multiple files are stored in variable testing. TESTING=$(ls -tr *.txt) echo $TESTING test.txt ab.txt bc.txt grep "word" "$TESTING" grep: can't open test.txt ab.txt bc.txt Giving me an error. Is there any other way to do it other than for loop ...

Python CLI tool - general parsing question

If possible I would like to use the following structure for a command however I can't seem to figure out how to achieve this in Python: ./somescript.py arg <optional argument> -- "some long argument" Would it be possible to achieve this in a feasible manner without too much dirty code? Or should I just reconsider the syntax (which is p...

how to find variable is empty or "" in shell script

how to find variable is empty in shell script ...

Good book for learning Bash shell?

I want to learn how to write shell scripts. Particularly I want to write a svn post-commit script to upload files from a test server to a production server. I am sure I will want to write more as I get more into it. I have very little linux/unix knowledge. Can anyone recommend a good book? ...

Extract log file

Hi, xxxxxxxxmessageyyyyyyymessagexxxxxxxxxx xxxxxxxxmessagezzzzzzzmessagexxxxxxxxxx xxxxxxxxmessageaaaaaaamessagexxxxxxxxxx xxxxxxxxmessageyyyyyyymessagexxxxxxxxxx The above is my log file I need to extract the phrase which is inside the message tag and I need to save the distinct messages in a file in the above example I need to ...

Shellscript - Adding a value in the PATH Variable

Guys, In my company we use firebird and everytime we install it in a new computer we need to add the firebird's path. I'd like some help to create a shell script to add this value in this path. ...

shell script: recursively find a file with a keyword

How to find all files with a specific key word in a directory with subdirectories. For example, given a directory r_dir and subdirectoris d1, and d2, I need find all files contains "key_word" under r_dir and d1 and d2. ...

Where does scripting fit in today

I was wondering what place scripting has in today's world of IDEs and GUIs. I'm new to programming and am wondering at what point I should, if at all, open up the PowerShell terminal for a particular task. What do people here use scripting for and how important is it to a modern developer working full time with C++/C#/Java? ...

sequentially executing background processes unix

Hi, I have two scripts say 'S1' and 'S2'. I execute these scripts as, nohup S1 & nohup S2 & But I would like them to execute sequentially. ie., S2 should execute only on successful completion of S1. How should I go about doing this?. How can I know when S1 finishes execution?. Any examples would be much appreciated. T...

while read loop + create aproccess in the while loop

Hi all dear friends The following test script has a problem. When I add the line (sleep 5 ) & in the script then the "while read" loop does not read all lines from the file, but only prints the first line. But when I remove the ( sleep 5 ) & from the script, then the script prints all lines as defined in the file. Why the ( sleep 5 ) ...