bash

How to line up columns using paste(1)? or how to make an aligned table merging lines in the shell?

Hi, I want to merge lines such that the merged lines are aligned on the same boundary. UNIX paste(1) does this nicely when lines all meet at the same tab boundary, but when lines differ in size (in the file that lines are being merged into), the text comes out awkward. Example of paste(1) that has the desired effect: $ echo -e "a\nb\n...

Determine stale data

Say I have a file of this format 12:04:21 .3 12:10:21 1.3 12:13:21 1.4 12:14:21 1.3 ..and so on I want to find repeated numbers in the second column for, say, 10 consequent timestamps, thereby finding staleness. 12:04:21 .3 12:10:21 1.3 12:14:21 1.3 12:10:21 1.3 12:14:21 1.3 12:12:21 1.3 12:24:21 1.3 12:30:21 1.3 12:44...

Delete lines containing a range pattern in 4rd columns

In a file 4th column contains a floating point numbers dsfsd sdfsd sdfds 4.5 dfsdfsd I want to delete the entire line if the number between -0.1 and 0.1 (or some other range). Can sed or awk do that for me? thanks ...

Alternative to scp, transferring files between linux machines by opening parallel connections

Hi, Is there an alternative to scp, to transfer a large file from one machine to another machine by opening parallel connections and also able to pause and resume the download. Please don't transfer this to severfault.com. I am not a system administrator. I am a developer trying to transfer past database dumps between backup hosts and ...

How can I convert a shapefile from AGD66 to GDA94 from a script, using open source libraries

How can I convert a shapefile from AGD66 to GDA94 programmatically, using open source libraries? I don't want to use arcgisscripting because I don't have a licence. This needs to be automatable. A bash or python script would be acceptable. This is a little more complicated than a normal reprojection, because a different ellipsoid is ...

linux script that monitors file changes within folders (like autospec does!)

I want to automatically kick off a build whenever a file changes. I've used autospec (RSpec) in Ruby and loved that. How can this be done in bash? ...

Smart auto-completition for staged git file names, used with difftool

I'd like to have a smart auto-completition of currently staged file names when using git diff. Example: modified: DIR1/LongCamelCaseFileName.h modified: DIR1/AnotherLongCamelCaseFileName.m modified: DIR1/AndThereAreALotOfThemInDir1.m modified: DIR2/file4.m and here, using bash tab-auto-complete functionality I'd like to use ...

Help with basic shell script. /bin/sh: source: not found

My cron : 45 10 * * * source /home/ThinkCode/Test/hello.sh hello.sh : #!/bin/bash echo "helloworld" The error it emails me : /bin/sh: source: not found What am I doing wrong? It is configuration/environment specific, so Googling didn't help much! Thanks.. ...

git: changelog day by day

How to generate changelog of commits groupped by date, in format: [date today] - commit message1 - commit message2 - commit message3 ... [date day+3] - commit message1 - commit message2 - commit message3 ... (skip this day if no commits) [date day+1] - commit message1 - commit message2 - commit message3 ... [date since] - commit messa...

Subversion svn update - Not working

Hi guys, I'm trying to setup subversion, so everytime someone commits a change, it updates a working directory that we'll use on a dev box as the 'test' site. I've setup post-commit, and added the line: #!/usr/bin/perl /usr/bin/svn update /home/administrator/sites/checkmyid --username root --password xxx Can anyone tell me why this ...

How to "zero" a file with 1's

I'll often create a file of a particular size with a trick like dd if=/dev/zero of=1gb.dd bs=1M count=1024 or perhaps even dd if=/dev/urandom of=1gb.dd bs=1M count=1024 dd if=/dev/random of=1gb.dd bs=1M count=1024 But what if I want to get all 1's instead of 0's or random? ...

Using AWK find a smallest number in a second column bigger than x

I have a file with two columns, sdfsd 1.3 sdfds 3 sdfsdf 2.1 dsfsdf -1 if x is 2 I want to print sdfsdf 2.1 How to express it in awk (bash or sed is fine too) ...

Deleting a folder that contains symlinks

If I rm -rf a folder that has soft links in it, will it try to follow those links and delete the corresponding folder, or will it simply unlink them? I have a copy of my home directory with sym links in it, and I'm scared to rm -rf it in case it follows those links and blows up the corresponding folders... ...

Check if a symlink has changed

I have a daemon that, when it's started, loads its data from a directory that happens to be a symlink. Periodically, new data is generated and the symlink updated. I want a bash script that will check if the current symlink is the same as the old one (that the daemon started with) and if not, restart the daemon. My current thought is: i...

Uniq in awk; removing duplicate values in a column using awk

I have a large datafile in the following format below: ENST00000371026 WDR78,WDR78,WDR78, WD repeat domain 78 isoform 1,WD repeat domain 78 isoform 1,WD repeat domain 78 isoform 2, ENST00000371023 WDR32 WD repeat domain 32 isoform 2 ENST00000400908 RERE,KIAA0458, atrophin-1 like protein isoform a,Homo sapiens mRNA for KIAA0458 prote...

Bash script to monitor ISDN connection

On a Ubuntu 10.04 Server I would like to do the following with a bash script: Create a service that monitors the ISDN connection and if downtime exceeds 60 seconds forces reconnect. My current solution looks something like this: #!/usr/bin/bash LOGFILE=/home/msw/router/ping-stats.txt TIME="`date +%C%y%m%d%H%M`" /sbin/ping -c 1 google.c...

Is there a good free (prefrerably PDF) bash tutorial online?

I am finding myself doing a lot more messing around with scripts than I used to and my lack of knowledge in this area (and linux sysadmin/security in general), is becoming a hindrance. Can anyone recommend a good online resource for bash scripting/linux admin. Preferably, it will be in pdf format, so I can copy it (single file) onto my ...

how to run few vim commands in a raw

Hello. This is really noob question. There is set of vim commands : command1 : command2 etc., which I would neet to type in in a raw quite often. How to I make it automatic? It is simple regexp replace command set, however I cannot script those in sed, since it involves non-latin locales and for some reason vim handles non-latin r...

What size of folders show ls -la

Possible Duplicate: When running ls -l, why does the filesize on a directory not match the output of du? Hi. I'm interesting in information what show me output ls -la in linux. So, default size is 4K. But if there are a lot of files, maybe with zero size, such as PHP sessions =), the size != 4K. What showing me ls -la? And a...

BASH: Checking for environment variables

Hi folks, I am trying to check the value of an environment variable and depending on the value do certain things and it works fine as long as the variable is set. When it isn't though I get a whole bunch of errors (as BASH is trying to compare the string I specify with an undefined variable, I guess) I tried implementing an extra check...