I'm running MSYSGIT on Windows and I want to be able to execute SQL statements against a SQL server directly from the bash console and bash scripts. Is this possible, and if so, how do I do it? Thanks!
...
For example, say I have a text file example.txt that reads:
I like dogs.
My favorite dog is George because he is my dog.
George is a nice dog.
Now how do I extract "George" given that it is the first word that follows "My favorite dog is"?
What if there as more than one space, e.g.
My favorite dog is George .....
Is there a wa...
end goal is to have the bash run something like
php script.php argument1 argument2 argument3
however, I want to ask the user for argument1,2, and 3. which will construct the above and run it.
...
Hi everyone,
i am trying to make a bash shell script that can add a name value pair to a text file, for example TEST=true. I am trying to make it so if the user tries to add a name that already exists for example TEST=false it does not let them do it. Can anyone tell me how to use the expr command to extract any text before the '=' ch...
Hello...
I have some bash scripts, some simple ones to copy, search, write lines to files and so on.
I am an Ubuntu. and I've searched in google, but it seems that everybody is doing that on python.
I could do these on python, but since I am not a python programmer, I just know the basics.
I have no idea of how calling a sh script from...
I need to extract some information from a log file using a shell script (bash). A line from the log file usually looks like this:
2009-10-02 15:41:13,796| some information
Occasionally, such a line is followed by a few more lines giving details about the event. These additional lines do not have a specific format (in particular they d...
Hi,
i am trying to remove a line that contains a particular pattern in a text file. i have the following code which does not work
`grep -v "$varName" config.txt`
can anyone tell me how i can make it work properly, i want to make it work using grep and not sed
...
while [ $done = 0 ]
do
echo -n "Would you like to create one? [y/n]: "
read answer
if [ "$(answer)" == "y" ] || [ "$(answer)" == "Y" ]; then
mkdir ./fsm_$newVersion/trace
echo "Created trace folder in build $newVersion"
$done=1
elif [ "$(answer)" == "n" ] || [ "$(answer)" == "N" ]; then
$done=2
else
echo ...
I've mastered the basics of Bash compound conditionals and have read a few different ways to check for file existence of a wildcard file, but this one is eluding me, so I figured I'd ask for help...
I need to:
1.) Check if some file matching a pattern exists
AND
2.) Check that text in a different file exists.
I know there's lots of way...
Hi, I have a daily cron task which automatically unrars a rar file and processes it's contents, however, the contents are now password protected so i'm wondering if there's a reliable way to echo the password when prompted? The password prompt comes from the UNRAR program i've installed, running on CentOS. Thanks for any help!
...
Assuming that there are only primary partitions on a disk, what is the best way to find the current number of partitions?
Is there any better way than:
fdisk -l > temp
#Following returns first column of the last line of temp e.g. /dev/sda4
lastPart=$(tail -n 1 temp | awk '{print $1}')
totalPartitions=$(echo ${lastPart:8})
$totalParti...
I have a strange issue, relating to running a BASH script via cron (invoked via crontab -e).
Here is the script:
#!/bin/bash
SIG1="$(iwconfig wlan0 | awk '/Quality=/ { print $2} ' | cut -c 9-10)"
SIG2="$(iwconfig wlan0 | awk '/Quality=/ { print $2} ' | cut -c 12-13)"
echo "$SIG1:$SIG2" >> test.txt
exit
When run from the commandline...
I have put the following in my ~/.localsh file to customize my bash prompt when working with git.
Basically I want to get the current branch displayed in my terminal.
The gitk tool shows branches with green background and black foreground, so thats what I'm trying to do.
What I have works, but when I press the up arrow on the keyboard ...
I work in a research group and we use the PBS queuing system. I'm no PBS master, but I wanted to script a search for if a job was running. To do this I first grab a string of all the jobs by using the results of a qstat call as my argument to qstat -f and then taking the detailed list of all jobs and searching it for the submitted file...
I want to sort the words on lines in a file line by line and I want the ouptut to be lines with the words sorted alphabetically.
for example:
queue list word letter gum
another line of example words
...
I want the output to be:
gum letter list queue word
another example line of words
...
I can't seem to get it to wo...
Hello, i was making a bash script for my server which pack some directories with RAR and upload it to other ftp server, so some folders are big and i have to rar them in parts and have to wait for all parts to be rared before uploading them, which consumes lots of time and space
so i want to do it more fast like, upload every rared par...
This is probably a very simple question to an experienced person with UNIX however I'm trying to extract a number from a string and keep getting the wrong result.
This is the string:
8962 ? 00:01:09 java
This it the output I want
8962
But for some reason I keep getting the same exact string back. This is what I've tried
pid=$(e...
I'm trying to grovel through some other processes environment to get a specific env var.
So I've been trying a sed command like:
sed -n "s/\x00ENV_VAR_NAME=\([^\x00]*\)\x00/\1/p" /proc/pid/environ
But I'm getting as output the full environ file. If I replace the \1 with just a static string, I get that string plus the entire environ ...
I'm trying to use something in bash to show me the line endings in a file printed rather than interrupted. The file is a dump from SSIS/SQL Server being read in by a Linux machine for processing.
Is there any switches within vi, less, more, etc?
In addition to seeing the line-endings, I need to know what type of line end it is (CRLF or...
I have a shell script that launches a Maven exec:java process -
exec mvn exec:java -Dexec.mainClass=... -Dexec.args="$*"
Now sadly if I run
./myMagicShellScript arg1 "arg 2"
the single string arg 2 doesn't make it through as a single argument as I'd like.
Any thoughts as to how to escape / pass things through properly (perferably ...