bash

Use bash to read a file and then execute a command from the words extracted

FILE: hello world I would like to use a scripting language (BASH) to execute a command that reads each WORD in the FILE above and then plugs it into a command. It then loops to the next word in the list (each word on new line). It stops when it reaches the end of the FILE. Progression would be similar to this: Read first WORD fr...

Getting -bash: mvn: command not found

Hi. I tried setting the Maven PATH in .profile file as well using export commands in terminal(Mac OSX). But, on running mvn commands, getting -bash: mvn: command not found Please help. ...

modify file content

I'm installing a lighttpd server on a remote machine using a bash script. After installation, I need to configure the port for the server. The system says I don't have permission to modify the file /etc/lighttpd/lighttpd.conf even though I do sudo echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf How shall I modify this? ...

How can I use FIND to recursively backup multiple subversion repositories

At the moment our backup script explicitly runs svnadmin hotcopy on each of our repositories every night. Our repos are all stored under a parent directory (/usr/local/svn/repos) Our backup script has a line for each of the repos under that directory along the lines of: svnadmin hotcopy /usr/local/svn/repos/myrepo1 /usr/local/backup/myre...

Embedded console tools functionality in application

I'm currently developing an application that happens to require some file preprocessing before actually reading the data. Doing it externally was not a possibility so I came up with a fork & execve of "cut options filename | sort | uniq -c" etc... and I execute it like that. However I thought that maybe there was already another option...

script to add files to SVN with filters

My bash scripting is weak. I want to create a script that filters and add files to the svn. So far i have this ls | egrep -v "(\.tab\.|\.yy\.|\.o$|\.exe$|~$)" I tried to output it using exec but couldnt figure out how. Before that I checked if svn add uses regex. I am not sure if it does and i couldnt figure out how to reverse the ab...

How do I get $(/bin/printf -6) to return -6 and not think -6 is an option.

I have a bash shell script which has the line: g=$(/bin/printf ${i}) when ${i} contains something like -6, printf thinks its being passed an option. It does not recognize the option so produces an error. if wrap ${i} in quotes, printf still thinks its being passed an option. g=$(/bin/printf "${i}") if I escape the quotes, variab...

Why aliases in a non-interactive Bash shell do not work

I am trying to use aliases in a non-interactive bash shell. I have defined my aliases in ~/.bashrc and I have set the variable BASH_ENV=~/startUpFile . The contents of the startUpFile are source ~/.bashrc I can see that my aliases are recognized, when I execute the "alias" command. However, if I try to use an alias defined in ~/.bash...

How to filter out a set of strings A from a set of strings B using Bash

Hi, I have a list of strings which I want to remove from a super set of another strings, not in a any specific order and thus constructing a new set. Is that doable in Bash? ...

Building R Packages using Alternate GCC

The systems I work with have GCC 4.5 (experimental) in /usr/local/bin/gcc which has proven to be problematic for some R packages. I would like to instead use system GCC in /usr/bin/gcc. I have tried setting CC and CXX in the Bash configuration files (.bashrc, .bash_profile etc.) as well as on the command line, but although Bash recogniz...

Splitting string into array

I want to split the string and construct the array. I tried the below code: myString="first column:second column:third column" set -A myArray `echo $myString | awk 'BEGIN{FS=":"}{for (i=1; i<=NF; i++) print $i}'` # Following is just to make sure that array is constructed properly i=0 while [ $i -lt ${#myArray[@]} ] do echo "Element $i:$...

Merge two text files specific position

I need to merge two files with a Bash script. File_1.txt TEXT01 TEXT02 TEXT03 TEXT04 TEXT05 TEXT06 TEXT07 TEXT08 TEXT09 TEXT10 TEXT11 TEXT12 File_2.txt 1993.0 1994.0 1995.0 Result.txt TEXT01 TEXT02 1993.0 TEXT03 TEXT04 TEXT05 TEXT06 1994.0 TEXT07 TEXT08 TEXT09 TEXT10 1995.0 TEXT11 TEXT12 File_2.txt need to be merged at this spe...

Inline SED regular expression question

I work for a company that offers webhosting and DNS services. We are trying to migrate everything over to new servers and we've often run into stale zonefiles on our servers as customers have changed their authoritative servers to someone else. I am trying to write a script that will check whois, ns, and SOA information to determine if...

inputbox and menubox simultaneously

Hi. How to display simultaneously an inputbox and a menubox? dialog --title "Title" \ --backtitle "Terms" \ --menu "Foo" 15 50 4 \ Date/time "Displays date and time" \ Calendar "Displays a calendar" \ Editor "Start a text editor" \ Exit "Exit to the shell" \ --inputbox "Your name!" 8 60 retval=$? case $retval in 0) echo 'The name is '$...

How to use sed to test and then edit one line of input?

I want to test whether a phone number is valid, and then translate it to a different format using a script. This far I can test the number like this: sed -n -e '/(0..)-...\s..../p' -e '/(0..)-...-..../p' However, I don't just want to test the number and output it, I would like to remove the brackets, dashes and spaces and output that....

Connecting Two Bash Commands

I have Ubuntu Linux. I found one command will let me download unread message subjects from Gmail: curl -u USERNAME:PASSWORD --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p" ...and then another comma...

linux: kill background task

How do I kill the last spawned background task in linux? Example: doSomething doAnotherThing doB & doC doD #kill doB ???? ...

bash loop between two given dates

I'm trying to create a script that will loop through files that have their filenames written in the following format: yyyymmdd.hh.filename. The script is called with: ./loopscript.sh 20091026.00 23 ./loopscript.sh 20091026.11 15 ./loopscript.sh 20091026.09 20091027.17 The need is for the script to check each hour between those two g...

bash: split output of command by columns

I want to do this: run a command capture the output select a line select a column of that line Just as an example, let's say I want to get the command name from a $PID (please note this is just an example, I'm not suggesting this is the easiest way to get a command name from a process id - my real problem is with another command who...

Bash script to edit a bunch of files

To process a bunch of data and get it ready to be inserted into our database, we generate a bunch of shell scripts. Each of them has about 15 lines, one for each table that the data is going. One a recent import batch, some of the import files failed going into one particular table. So, I have a bunch of shell scripts (about 600) wher...