bash

New Application Process from Bash Shell

I'm relearning UNIX commands to use git on windows using MINGW32. When I launch a program, for example "$ notepad hello.txt" I can't use the shell again until I close the notepad file or CTRL-C in the shell. How do I essentially fork a new process so I can use both programs? ...

Regular expression in BASH

Hello everyone, I was hoping someone could answer my quick question as I am going nuts! I have recently started learning regular expressions in my Java programming however am a little confused how to get certain features to work correctly directly in BASH. For example, the following code is not working as I think it should. echo 2222 |...

help with grep [[:alpha:]]* -o

file.txt contains: ##w## ##wew## using mac 10.6, bash shell, the command: cat file.txt | grep [[:alpha:]]* -o outputs nothing. I'm trying to extract the text inside the hash signs. What am i doing wrong? ...

Import files directly to SVN repo without checking out first

Hi, I am using SVN and have a repository on a remote machine. Sometimes, when working on my local machine I realize that I need to add some new files to the repo. The usual procedure I know would then be: 1- at the current folder on my local machine checkout the whole SVN repo 2- enter there 3- copy the interesting file here 4- commit ...

redirect stdout and stderr to a single file with prefixes

I am writing a bash script and need to redirect the stdout and stderr output of a command i run to a single file, prefixing each line with stderr or stdout, accordingly. is there a simple way to do this? ...

Need help understanding a bash command

It's actually a combination of php and bash: exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile)); I don't understand what 2>&1 & echo $! is there for? ...

Bash completion symfony

How can I make symfony completion in bash? Have ubuntu 9.10. It's hard to write own alias. Anyone know where can I find it? I find http://trac.symfony-project.org/wiki/BashCompletion - but it is for symfony 1.1. Is it compatible with 1.4 ? ...

What is the best, python or bash for selectively concatenating lots of files?

Hi, I have around 20000 files coming from the output of some program, and their names follow the format: data1.txt data2.txt ... data99.txt data100.txt ... data999.txt data1000.txt ... data20000.txt I would like to write a script that gets as input argument the number N. Then it makes blocks of N concatenated files, so if N=5, it wou...

What happened to the TMP environment variable?

I always heard that the proper way to find the temporary folder on a UNIX machine was to look at the TMP environment variable. When writing code that worked on Windows as well as Linux, I would check for TEMP and TMP. Today, I discovered that my Ubuntu install does not have that environment variable at all. I know it seems you can alw...

Why is the value of this string, in a bash script, being executing?

Hello Why is this script executing the string in the if statement: #!/bin/bash FILES="*" STRING='' for f in $FILES do if ["$STRING" = ""] then echo first STRING='hello' else STRING="$STRING hello" fi done echo $STRING when run it with sh script.sh outputs: first lesscd.sh: line 7: [hello: command not found le...

How to get my geolocation in bash

I am looking for a good geolocation api to use from bash. I want this call to return at the very minimum the name of the city I am in, and the state. I imagine that there must be some site I can curl, or some scripting language that has a package that works. The machine does not have a GPS, but it does use wireless internet most of the ...

How to get the list of files in a directory in a shell script?

Hi, I'm trying to get the contents of a directory using shell script. My script is: for entry in `ls $search_dir`; do echo $entry done where $search_dir is a relative path. However, $search_dir contains many files with whitespaces in their names. In that case, this script does not run as expected. I know I could use for entry i...

Work with a local copy of the "master" SVN repo

Hi, at work, we have a SVN repo, which we access to thorugh http, like: svn co http://user@machine/PATH even at work and for some misterious reasons, teh connections between local machines and the repo machine are very slow, but the connection between home and work is almost impossible. I wonder if I could do somethin like: 1- get ...

Get color output in bash

Hi, when compiling some projects on linux terminal, I get usually a long output consisting of a lot of information. Usually this information is MONOCHROME. I wonder if bash can be modified somehow, so in all outputs or in some specific outputs (like from Makefile, etc) I can get different colors dependeing on, for instance: make[1]: Le...

Bash: how to supress newlines?

I'm trying to extract fields from a pipe-delimited file and provide them as arguments to an external program in a loop. The file contains lines like this: value1|value2 value3|value4 So I came up with: while read line; do echo -n "${line}" | awk -F '|' '{print $1}'; echo -n " something "; echo -n "${line}" | awk -...

Is it possible to get a graphical representation of gprof results?

Hi, I am interested in getting the profiling of some number crunching program. I compiled it with -g and -pg options and linked it and got it gmon.out. After reading the info (plain text) it looks a bit ugly. I wonder if there are some open source tools for getting a graphical representation of the 10 functions where the program spends ...

Find declaration and definition of function using bash

Hi, I am having a look af a big C++ project with more than 100 files. Given a certain function name, how can one find just using bash tools like find or grep, the declaration and the defintion of a function? Thanks ...

How to search an expression in a file from a bash script?

I have a bash script. I need to look if "text" exists in the file and do something if it exists. Thanks in advance ...

What is common between environments within a shell terminal session?

I have a custom shell script that runs each time a user logs in or identity is assumed, its been placed in /etc/profile.d and performs some basic env variable operations. Recently I added some code so that if screen is running it will reattach it without needing me to type anything. There are some problems however. If I log-in as root...

How to get the first line of a file in a bash script?

I have to put in a bash variable the first line of a file. I guess it is with the grep command, but it is any way to restrict the number of lines? Thanks in advance ...