bash

bash: A: unrecognized history modifier

Hi there, After running a c program, giving it some input on the command line (the program simulates a pushdown automata), I get the following response: bash: A: unrecognized history modifier I have googled, but I can't find an explanation as to what this means exactly. My program works with other test input, so I assume it's somethin...

bash find xargs grep only single occurence

hi. maybe it's a bit strange - and maybe there are other tools to do this but, well.. i am using the following classic bash command to find all files which contain some string: find . -type f | xargs grep "something" i have a great number of files, on multiple depths. first occurence of "something" is enough for me, but find continue...

check if timestamp is in certain range using bash script

Say I have a bunch of time stamps As I iterate over these timestamps, 01:23:00 12:34:14 17:09:12 ... I want to include only timestamps between 08:00:00 and 17:00:00 please suggest ...

Bash script: regexp reading numerical parameters from text file

Greetings! I have a text file with parameter set as follows: NameOfParameter Value1 Value2 Value3 ... ... I want to find needed parameter by its NameOfParameter using regexp pattern and return a selected Value to my Bash script. I tried to do this with grep, but it returns a whole line instead of Value. Could you help me to find ...

Problem executing script using Python and subprocces.call yet works in Bash

Hello, For the first time, I am asking a little bit of help over here as I am more of a ServerFault person. I am doing some scripting in Python and I've been loving the language so far yet I have this little problem which is keeping my script from working. Here is the code line in question : subprocess.call('xen-create-image --hostna...

How to use the .* wildcard in bash but exclude the parent directory (..)?

There are often times that I want to execute a command on all files (including hidden files) in a directory. When I try using chmod g+w * .* it changes the permissions on all the files I want (in the directory) and all the files in the parent directory (that I want left alone). Is there a wildcard that does the right thing or do I ne...

How can I process a Perl array element in a shell script?

For example: In Perl: @array = (1,2,3); system ("/tmp/a.sh @array" ); In my shell script, how do I handle this array in shell script? How do I handle the shell script to receive the arguments, and how do I use that array variable in shell script? ...

Symlinking folders in bash

I want a folder /public_html to symlink to /current/app/webroot, both are in the same directory I have tried ln -s public_html current/app/webroot amongst other things, but no joy so far. Any ideas? ...

groovy bash command

I need to run this command in Groovy when click on button bash copy.txt > copy.log I tried with execute but not worked out . Could any one please help me thanks in advance sri.. ...

Why does sh/bash set command line parameter values when trying to set environment variable?

A question on basics : While tuning environment variables for a program launched from a script, I ended up with somewhat strange behaviour with sh (which seems to be actually linked to bash) : variable setting seems to mess up with command-line parameters. Could somebody explain why does this happen? A simple script: #! /bin/sh # Mes...

Bash Templating: How to build configuration files from templates with Bash?

Hello. I'm writting a script to automate creating configuration files for Apache and PHP for my own webserver. I don't want to use any GUIs like CPanel or ISPConfig. I have some templates of Apache and PHP configuration files. Bash script needs to read templates, make variable substitution and output parsed templates into some folder. ...

Simple rvm gui manager application

Hi all, i'm trying to write a simple gui application to manage ruby version manager. i started with some stuff like testing how ruby's %x[ ] works.. i made this function def do ( command ) %x[#{command}] end if i try to use this function with one of the rvm commands like "rvm list" or rvm -v i get a command not found: error. the s...

How do I write to a file and print to a terminal concurrently in Unix?

I have a little bash function to log my Macports outputs to a file (since installs often spew little tidbits that are easy to lose in terminal noise), then I just cat the file to the terminal: function porti { command sudo port install $@ >> $1.log 2>&1; cat $1.log } Is there a way to do this concurrently? BTW I pass $@ to instal...

Folder Renaming After Tar Extraction

I have an tarball, myarchive.tar.gz. When I uncompress it using "tar -zxvf myarchive.tar.gz", it creates a folder myarchive-x980-2303-ssioo. What's the easiest way to automatically rename the extracted folder to ensure it matches the name of the archive? I've checked tar's manpage, but it doesn't seem to have an option for this. ...

execute command hard coded in script not work when its in a variable

this works: nc shldvgfas005 6155 < temp.6153 this hangs: cmd="nc shldvgfas005 6153 < temp.6153"; $cmd this gives an error: cmd="nc shldvgfas005 6153 < temp.6153"; "$cmd" -bash: nc shldvgfas005 6153 < temp.6153: command not found HELP! ...

Inlining the LaTeX \input Command

I'm looking a program to recursively inline all \input{} commands in a LaTeX file. By "recursively", I mean doing the inlining iteratively until no \input{} command remains in the final LaTeX file. I've already come across the flatten package. But, for some reason, my TeXLive distribution doesn't install it. When I execute the command s...

./configure : /bin/sh^M : bad interpreter

Hello there, I've been trying to install lpng142 on my fed 12 system. Seems like a problem to me. I get this error [root@localhost lpng142]# ./configure bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory [root@localhost lpng142]# How do I fix this? and for more details, I shall include the /etc/fstub file deta...

bash copy with variable

I'm trying to copy files to the current directory using a bash script. In order to handle paths that need escaping a variable is used that is escaped and then supplied to the cp command. The cp command is complaining with: usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n]...

How to define a logout script for the Cygwin/X X Server

Is there a way to define a logout script for the Cygwin/X X Server? I'm looking for something like .bash_logout, but only run when the Cygwin/X X Server shuts down. I'm using .startxwinrc to start programs when the X server starts, but I haven't found something similar for when it shuts down. Any ideas? ...

fixed width bash prompt

I'd like to set my bash prompt to a fixed width, and make up the difference in space before the $, so whether long or short, my prompt remains the same width: [name@host] ~/Directory/Dir...Another/LastDir $ [name@host] ~/Directory(branch) $ Currently, in a short directory path my prompt looks something like this: [nam...