bash

Using gettext in bash.

How to use gettext in bash script? I only found this page, but I don't understand it. Localization My script is written like this: #!/bin/bash . lang_file.sh echo $LANG_HELLO_WORLD And lang_file.sh look like that: #!/bin/bash LANG_HELLO_WORLD="Hello World" I want to change lang_file.sh to something using gettext, like this:...

Extraction of data from a simple XML file

I've a XML file with the contents: <?xml version="1.0" encoding="utf-8"?> <job xmlns="http://www.sample.com/"&gt;programming&lt;/job&gt; I need a way to extract what is in the <job..> </job> tags, programmin in this case. This should be done on linux command prompt, using grep/sed/awk. ...

How to transform multiple line into one line in bash stdout ?

Hello, I sometimes do this in my shell : sam@sam-laptop:~/shell$ ps aux | grep firefox | awk '{print $2}' 2681 2685 2689 4645 $ kill -9 2681 2685 2689 4645 Is there a way I can transform the multiple lines containing the PIDs into one line separated by spaces ? (It's a little bit annoying to type the PIDs every time and I really wou...

basics of using cut awk grep and sed...

Hello there, I'm trying to extract the year from this output : sam@sam-laptop:~/shell$ date Mon Feb 8 21:57:00 CET 2010 sam@sam-laptop:~/shell$ date | cut -d' ' -f7 2010 sam@sam-laptop:~/shell$ date | awk '{print $6}' 2010 Are there any other ways to get the same result ? using maybe grep, sed etc ? Merci ! ...

Ignore a path entry with bash tab-completion

I have two commands, foo and foo-bar, where foo is a symlink to foo-bar. I want to be able to type f+TAB (pretend these are the only two commands on the path that begin with f) and have one of them be completed (meaning the full name and the space after). What ends up happening though is that it completes to just foo (no space) because ...

Using linux "cut" with stdin

I'm trying to pipe data into "cut" to, say, cut away the first column of text. This works $ cat test.txt | cut -d\ -f2- Reading from stdin also works: $ cut -d\ -f2- - ? doc/html/analysis.html ? doc/html/classxytree-members.html <CTRL+D> However, as soon as a pipe is involved, it doesn't accept my <CTRL+D> anymore, and I can't si...

How can I find out a files "mime-type(Content-Type?)"?

Is there a way to find out the MIME-TYPE (or is it called "Content-Type"...) of a file in a linux bash script? The reason I need it is because imageshack appears to need it to upload a file as for some reason it detects the .png file as an "application/octet-stream"… I'v checked the file, and it really is a .png $ cat /1.png ?PNG (wi...

How to run a command recursively on all files except for those under .svn directories

Here is how i run dos2unix recursively on all files: find -exec dos2unix {} \; What do i need to change to make it skip over files under .svn/ directories? ...

How to get the IP address from $SSH_CLIENT

$SSH_CLIENT has IP address with some port info, and echo $SSH_CLIENT gives me '10.0.40.177 52335 22', and Running if [ -n "$SSH_CONNECTION" ] ; then for i in $SSH_CLIENT do echo $i done fi gives me 10.0.40.177 52335 22 And I see the first element is the IP address. Q : How can I get the first element of $SSH_CLIENT...

How to use float numbers on BusyBox?

I have little computer, MMnet1000 with BusyBox, and compiling anything on it is nightmare. I want to do something simple like "0,5*2", but can't without additional software. I tried "expr", "let", and just can't do any operation with float numbers. Is there something I can do? UPDATE --- Carl Norum root@MMnet:/kafka# dc -ash: dc: no...

how can i compare strings in bash script?

I need to compare a variable to some string (and do something if they match). How can i do the comparison? ...

Cygwin's bash can't run 'net use /user' command?

I run 'net use /user:"Someone" \somewhere', and it works well with cmd.exe. With the same cmd.exe, run 'bash --login -i' to use the cygwin/bash, and run the same command but I get the error message as follows. System error 67 has occurred. The network name cannot be found. Q: Why can't I run 'net use /user' command with cygwin/bash...

Paste to codepad.org using bash or curl

How can I paste to codepad.org from the commandline using curl? ...

Undeletable file due to backup script

I just wrote this backup script: #!/usr/bin/bash # the number of days to do the backup for. days=5; # the files to backup. location[0]='/opt/aDirectory/' location[1]='/extra/anotherDirectory/' # the location to copy the file to copyLocation='/users/JoeBlow/Backup/backup-'$(date | tr ' ' '-') # Log stuff mkdir $copyLocation echo "mad...

Bash script to setup a temporary SSH tunnel.

On CYGWIN, I want a BASH script to: create an SSH tunnel to a remote server. Do some work locally that uses the tunnel. Then shutdown the tunnel. The "shutdown part" has me perplexed. Currently, I have a lame solution. In one shell I run the following to create a tunnel. # Create the tunnel - this works! It runs forever, until sh...

Technique to compute next day's date from a date supplied via an arg?

Hi All, I'm having some trouble figuring this out. I have a script that checks a log file that is generated the day after the date specified by the script call. This is because the files fetched for the specified day's data won't be fetched until the day after. And when that cron runs in the morning, the log file will have a timestamp...

querying for memory details in shell

Hi, Is there a shell command to know about how much memory is being used at a particular moment and details of how much each process is using, how much virtual memory is left etc? ...

How to display status message on web page.

Hello, I have a bash script that checks for and deploys new .ear files to the JBoss server.I have linked this script to a web page, so that users can deploy their applications by clicking on the link. I have also been able to set a status message that the application is being deployed, when a user clicks on the link.(Done using Javascri...

bash shell program

!/bin/bash echo Enter the num read n for i in { 1..10 } do m=$(( n*i )) echo "$i * $n" = $m done i got error as for: 8: Illegal number: { kindly suggest a solution ...

Problem with temporary unnamed pipe in bash script

Hi, I have the following question: When I execute the following script directly in a terminal window, the commands behave as expected. $ diff <(echo tmp) <(echo tmp1) 1c1 < tmp --- > tmp1 However when I write the same command in a shell script #! /bin/bash diff <(echo tmp) <(echo tmp1) I get the following error message: $ sh tes...