shell

Removing leading \n while assaigning to a variable

I have a DB2 query in a shell script which return an integer value, but I am unable to store it in a variable. temp1= echo db2 -x "select max(id) from work.work_tb" I am getting this output when I run it, sh -x test.sh db2 -x select max(id) from work.work_tb echo 50 temp1= 50 So for some reason $temp1 is unable to get the value, ...

shell to filter prohibited words on a file

Good day shell lovers! basically i have two files: frequency.txt: (multiple lines, space separated file containing words and a frequency) de 1711 a 936 et 762 la 530 les 482 pour 439 le 425 ... and i have a file containing "prohibited" words: stopwords.txt: (one single line, space separated file) au aux avec le ces dans ... so ...

shell_exec slow with php

Hi all I have a curl script multi that helps index my site every 10 minutes it pushes to a mysql db so I can search my site for users The script uses 2 MB per instance (which isn't bad) however every time I run the script it slows apache down ( i have a UNIX server) so badly it takes 30 seconds to search... I keep the mysql db conn...

vba check if specific process task id is still running

I am using the Shell() function to execute an external application in MS Access. Shell() returns a task ID of the specific process that was started. I need a way to check if that process is still running or if it has closed. I'm sure that I will need to do some sort of windows API call but I can't seem to find anything just now. ...

Delete newline in Vim

Is there a way to delete the newline at the end of a line in Vim, so that the next line is appended to the current line? For example: Evaluator<T>(): _bestPos(){ } I'd like to put this all on one line without copying lines and pasting them into the previous one. It seems like I should be able to put my cursor to the end of each ...

tilde expansion in environment variable

In my .sh file, I have this, cp $file $SOME_PATH, while $SOME_PATH is exported as export SOME_PATH="~/path/to/path/". But when I ran this .sh file, I got error message saying like * no such "~/path/to/path/" exists.* I replaced ~ as $HOME, then the error was gone. So what's up here with the tilde? Thanks in advance. ...

"sed" command in bash

Could someone explain this command for me: cat | sed -e 's,%,$,g' | sudo tee /etc/init.d/dropbox << EOF echo "Hello World" EOF What does the "sed" command do? ...

Bash, Perl, or Powershell? For Jobs/General

Despite knowing a good bit of C++......i actually don't know that much about scripting languages. I feel like however I need to learn more about them. However there are a fair bit of different ones, but which one would be the best one to learn for a job? (I am a CS graduate in December btw) or just a general "better" to work with. Power...

cd -1, -2, -3 etc in Z shell

Hi, How do you set up Z-shell so that typing cd - gives you a list of previously visited paths? cd -1, -2, -3 etc then take you to the directories. ...

Pretty-print for shell script

I'm looking for something similiar to indent but for (bash) scripts. Console only, no colorizing, etc. Do you know of one ? ...

bash: extract double from string

hello I have this string in bash: str=sdk.iphoneos4.1.sdk and I would like to have a variable with '4.1' in it is there any way to parse a float/double value in bash ? ...

To read from file and putting values in WHERE clause via shell script

Hello, Shell Script #! /bin/bash sqlplus -s <username>/<passwd>@dbname << EOF set echo on set pagesize 0 set verify off set lines 32000 set trimspool on set feedback off SELECT * FROM <dbname>.<tablename1> tr LEFT JOIN <tablename2> t2 ON t2.id2 = tr.id1 LEFT JOIN <tablename3> t3 ON t3.id2 = tr.id1 LEFT JOIN <tablename4> t4 O...

How to read lines from file, storing it and again start from the last stored line in UNIX

Hello, The shell script needs to read batch of lines (lets say first 150). then storing that values in variable. After the execution of the SQL, now it should read from 151 to 300. In this way, it will read lines in batch of 150 and storing it in a variable till 32000 lines are read. Script Looks Like #!/bin/bash t2val=$(cat...

Unix script to find all folders in the directory

Basically I need to run a Unix script to find all folders in the directory /fss/fin, if it exists; then I have tar it and move to another directory /fs/fi. This is my command so far: find /fss/fin -type d -name "essbase" -print Here I have mentioned folder name essbase instead of that I have to find all the folder in the /fss/fin. ...

Case sensitivity in shell script.

How to overcome the case sensitivity while accessing a file in unix using shell script.? I have a file namely file.txt in the designation path and in script while accessing the same file with the name FILE.txt it throws the error as Cannot open File. Please guide me how to access the file with case change in unix scripting. How to tur...

RESTful Dictionary Service?

Hi all, this is only loosely programming related. I wrote myself a shellscript, that extracts all acronyms from a text and writes them to a file. Now I would like to process that file to add the definitions. My first google hit suggested using curl and the dict:// url scheme. However I am behind a proxy, which does not seem to allow th...

AIX vg creation problem in shell script

Creating a volume group using mkvg -y trialvg xyz works but the same line represented like this mkvg -y $vg_name $dev_name in a shell script causes the following problem : bash-4.0# ./execute_AIX.sh Creating VG trialvg with device xyz Executing Command: mkvg -y trialvg xyz 0519-100 libodm: Cannot open the object class collection file. ...

remotely run a script sitting in a windows server from a unix box or from another desktop (Say windowS)

I have to run a batch job which sits in the windows server from my unix box. Or from my local machine. The win server has a userName/Pwd . How do i programmatically connect to the windows machine and run the batch? (The batch will change some file permissions in that machine) Please let me know if there is a better way of handling this ...

Conditional actions based on error in shell script

Hi, I have a bash script that watch's a directory for uploads. When it sees a xml file in the directory. The script takes the file and calls a java command line program that using xslt transforms the file. I want to mv the file to a different directory (errors) if the script or java command line program throws a error during processing...

How do I fix unix so that I can use the cursor on the shell?

I was able to use the up/dow arrow to cycle through previous commands, now when I press a directional key it outputs "^[[A". I'm running on a bash shell. How do I fix this? Thanks ...