bash

How do I select the line in bash terminal

Is it possible to select part of a string in the bash terminal and delete it at once, rather than navigating to a point in the command and backspacing it all?? thanks! ...

Simple timer to measure seconds an operation took to complete.

I run my own script to dump databases into files on a nightly basis. I wanted to count time (in seconds) it takes to dump each database, so I was trying to write some functions to help me achieve it, but I'm running into problems. I am no expert in scripting in bash, so if I'm doing it plain wrong, just say so and ideally suggest altern...

create alias with argument

I want an alias that produce folowing result: $cd /home/ok [clear screen] /home/ok total 452K -rwx--x--x 1 user gigl 16K Oct 1 14:08 ok0 drwx------ 5 user gigl 0 Oct 1 14:02 ok1 drwx------ 5 user gigl 0 Oct 1 13:59 ok2 drwx------ 9 user gigl 0 Oct 1 14:01 ok3 -rw------- 1 user gigl 32 Sep 30 14:36 ok4 I did a script l...

Bash: Permission denied when trying to open a file

I recently decided to try to learn some bash scripting and as a fun exercise I decided to make a script to open up a daily file for me to write notes in whenever the script is run. It worked fine until I logged out and back in to the system later, when I received an error /usr/local/bin/notes: line 45: /home/MY_USERNAME/notes/2010-10-0...

How to extend bash shell ?

Hello, would like to add new functionality to the bash shell. I need to have a queue for executions. What is the easy way to add new functionality to the bash shell keeping all native functions? I would like to process the command line, then let the bash to execute them. For users it should be transparent. Thanks Arman EDIT I just ...

Sorting content based on first field and outputting second field into new file

I've got a file which is like this: 3 EOE 5 APPLE 6 NOBODY i need to parse this and output all with '3' in the first column into filename.3, '4' into filename.4, etc... from the unix prompt ...

Generating permutations using bash

is it possible to write a bash script that can read in each line from a file and generate permutations for each? Using awk / perl is fine. File ---- ab abc Output ------ ab ba abc acb bac bca cab cba ...

How to iterate through all git branches using bash script

Hi, How can I iterate through all the local branches in my repository using bash script. I need to iterate and check is there any difference between the branch and some remote branches. Ex for branch in $(git branch); do git log --oneline $branch ^remotes/origin/master; done I need to do something like given above, but the issue...

Use Quicktime to covert an audio file from AAC to AC3 via CLI?

Basically I want to use Quicktime to convert an audio file from AAC to AC3, I thought I might be able to use Quicktime? But I can't seem to be able to find the CLI command for it. ...

Internationalizing Bash scripts

I've been following a tutorial from a recent edition of the Linux Journal which teaches how to internationalize Bash scripts. However, I'm having trouble getting it to work on my system (Ubuntu 10.04.) When I get to the part where I'm supposed to call "gettext," after setting the environment variable TEXTDOMAINDIR, I get: toby@toby-lapt...

get the return value of bat file in windows in unix ?

i have the following case :- i write bash file bbb in windows 2003 and but a return value = 3 by exit /b 3 then i execute this bash file from unix by this command :- ssh -l admin host 'cmd /c start c:\bbb' but when i print the return value i get ( 0 ) not ( 3 ) i print this value by `echo $? ' now how i can get a return value "exit cod...

Purpose of line : source ~oracle/.bash_profile in shell script

While executing a shell script involving database connection, my script showed me an Error :sqlplus not found : sqlplus -s username/paswd@DB_name > /home/user/sql.out << EOF But when i included the following statement, it started to work: source ~oracle/.bash_profile What is the purpose of this above line ? ...

Port Bash to Batch

At my school I want to automate the process of telling the students to go to class and play a song five minutes before class starts at the end of lunch. I wrote a Bash script that will play the announcement, a random song. After five minutes the script will fade out the music and kill VLC. I need this script run on Windows as the is the...

What is wrong with this use of PIPESTATUS in BASH?

I have a for loop that I pass through ssh to a server that is formatted to look kind of like this... i=0 for cmd in cmd_list; do ${cmd} | sed "s/^/OUTPUT_${i}_: /" & (( i++ )); done; wait The idea is that the for loop will run a list of commands that I give it and pipe each one to sed where sed prepends each line of output with a comm...

Thor equivalent or similar scripting framework for Javascript?

Is there a Thor equivalent (ruby tool) or similar scripting framework for Javascript that could be used to build scripts? ...

how to read STDOUT to a series of variables

I have a python script called mythicalPythonBindings.py. It outputs something like Establishing database connection chanid = 1952 starttime = 2010-09-29 08:12:00 endtime = 2010-09-29 08:30:00 basename = 1952_20100929081200.mpg stars = 0.0 I need to read this information into variables of the same name in a bash script. My bash scri...

xargs with command that open editor leaves shell in weird state

Hey guys, I tried to make an alias for committing several different git projects. I tried something like cat projectPaths | \ xargs -I project git --git-dir=project/.git --work-tree=project commit -a where projectPaths is a file containing the paths to all the projects I want to commit. This seems to work for the most part, firing...

how i can pass a file directory (path) as parameter ?

how i can pass a file directory (path) as parameter to 1. batch file in windows operating system 2. bash file in unix oprating system ...

Redirecting standard output to a file containing the pid of the logging process

I've searched for a while but i can't either find an answer or come up with a solution of my own, so I turn to you guys. First question I actually ask here :) I would like to run several instances of the same program, and redirect each of these programs' standard output to a file that contains that same process' pid, something like: my...

Redirecting standard output to a file containing the pid of the logging process

I've searched for a while but i can't either find an answer or come up with a solution of my own, so I turn to you guys. First question I actually ask here :) I would like to run several instances of the same program, and redirect each of these programs' standard output to a file that contains that same process' pid, something like: my...