bash

.vimrc action onclose

Hi, is it possible to use something like an "vim-close/exit"-Event to execute some last commands before vim quits? I use this lines in my config, to let vim set my screen-title: if $TERM=='xterm-color' exe "set title titlestring=vim:%t" exe "set title t_ts=\<ESC>k t_fs=\<ESC>\\" endif but when i close vim, the title is s...

kdialog progress bar "object not accessible" as root

Hi all I have a script containing lots of commands that need root rights. Instead of running all these command with sudo inside the script I prefer to run the whole script with sudo. This is also more comfortable to put it in the sudoers file. sudo ./script.sh However, I'd like to show the progress with a kdialog progress bar, which ...

Using file contents as command line arguements in BASH

I'd like to know how to use the contents of a file as command line arguments, but am struggling with syntax. Say I've got the following: # cat > arglist src/file1 dst/file1 src/file2 dst/file2 src/file3 dst/file3 How can I use the contents of each line in the arglist file as arguments to say, a cp command? ...

How to process file names with variables from a list in a file in Bash

I have a file "FileList.txt" with this text: /home/myusername/file1.txt ~/file2.txt ${HOME}/file3.txt All 3 files exist in my home directory. I want to process each file in the list from a bash script. Here is a simplified example: LIST=`cat FileList.txt` for file in $LIST do echo $file ls $file done When I run the script, I ...

BASH :: find file in archive from command line

i know how to find file with find # find /root/directory/to/search -name 'filename.*' but, how to look also into archives, as file can be ziped inside... thanx ...

Pass list of variables to bash script

I need to be able to read list of variables that follow certain parameter(similar to say mysqldump --databases db1 db2 db3) Basically script should be invoked like this: ./charge.sh --notify --target aig wfc msft --amount 1bln In the script itself I need to assign "aig wfc msft" either to a single variable or create an array out of t...

Reading java .properties file from bash

I am thinking of using sed for reading .properties file, but was wondering if there is a smarter way to do that from bash script? ...

Multi-threaded BASH programming - generalized method?

Ok, I was running POV-Ray on all the demos, but POV's still single-threaded and wouldn't utilize more than one core. So, I started thinking about a solution in BASH. I wrote a general function that takes a list of commands and runs them in the designated number of sub-shells. This actually works but I don't like the way it handles acc...

Bash command to recursively list files but sorting by classification

I often use the excellent find program in Bash to list files with certain filters. For example, in a Subversion (SVN) working copy, I sometimes wish to recursively list all files but excluding the .svn subdirectories as follows: find . -name '.svn' -prune -o -type f -print Today, I wanted to do something similar, but I also wanted to ...

home directory expansion (~) within an argument

When I enter the following (BASH): rdesktop -r disk:bacon=~/bacon host It does not expand to rdesktop -r disk:bacon=/home/me/bacon host It seems the "disk:" part is the problem as can be seen in: $ echo bacon=~/bacon disk:bacon=~/bacon bacon=/home/me/bacon disk:bacon=~/bacon How can I make tilde expand? ...

Set screen-title from shellscript

Hi, is it possible to set the Screen-Title with an shellscript? i thought about something like sending the key commands "Strg+A Shift-A Name " I searched for about an hour only how to emulate keystrokes in an shell-script - but didnt find the answer. Thanks for Help! Beerweasle ...

python or bash - adding " at beginning of line and ", at end of line

I have text file with something like first line line nr 2 line three etc And i want to generate "first line", "line nr 2", "line three", I wonder how to do this in python or maybe in bash if it's easier/quicker. I know there is different code for opening file and different for reading only one line in python(?) but i'm not sure wh...

How can I read a list of filenames from a file in bash?

I'm trying to write a bash script that will process a list of files whose names are stored one per line in an input file, something the likes of find . -type f -mtime +15 > /tmp/filelist.txt for F in $(cat /tmp/filelist.txt) ; do ... done; My problem is that filenames in filelist.txt may contain spaces, so the snipped above will exp...

cron + evolution data server + msync returning libebook-WARNING

Ok, i got a working synchronisation between mobile and evolution using opensync and the lib-evo2 module. issueing msynctool --sync w880i --filter-objtype note --filter-objtype event --filter-objtype todo --conflict n directly works fine, in a script like this: #!/bin/bash eval `dbus-launch --sh-syntax` export DBUS_SESSION_BUS_ADDRE...

Bash: what expands to all files in current directory recursively

I know **/*.ext expands to all files in all subdirectories matching *.ext, but what is a similar expansion that includes all such files in the current directory as well? ...

Variable Corruption in bash script

Given the following code I am expecting the variable $NewFile to be /var/ftp/pub/faxes/myfile.txt.pdf However my system is returning: ".pdf/ftp/pub/faxes/myfile.txt" $Ext returns: "txt" $oFileName returns: "/var/ftp/pub/faxes/myfile.txt" I have tried this a hundred different ways with no luck. PDF=".pdf" #extract the file.ext from t...

Lookup shell variables by name, indirectly

Let's say I have a variable's name stored in another variable: myvar=123 varname=myvar now, I'd like to get 123 by just using $varname variable. Is there a direct way for that? I found no such bash builtin for lookup by name, so came up with this: function var { v="\$$1"; eval "echo "$v; } so var $varname # gives 123 Which d...

Pass bash script parameters to sub-process unchanged

I want to write a simple bash script that will act as a wrapper for an executable. How do I pass all the parameters that script receives to the executable? I tried /the/exe $@ but this doesn't work with quoted parameters, eg. ./myscript "one big parameter" runs /the/exe one big parameter which is not the same thing. ...

Executing for-each in bash

I'm looking to write a Bash one-liner that calls a function once for each item in a list. For example, given the list foo bar baz and the program "cowsay", it would produce: _____ < foo > ----- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || _____ < bar > ---...

Switch user and output variable contents

I am writing a bash script and want to switch to another user, cd into a directory specified by MYDIR in the users bash_profile and list the contents. Currently I have: read username su - app${username} -c ls $MYDIR The output is nothing, my first guess is that it is a problem reading $MYDIR from the users profile as doing it manuall...