shell

how to make $(eval $(shell ...)) work in GNU make

make syntax is newline-delimited, but $(shell ...) replaces newlines with whitespace. So what's the least ugly way to do $(eval $(shell program-that-emits-makefile-fragment)) which doesn't work the way one might like. ...

generate blank files

I want to empty 3 files or generate them if they do not exist. Is the following command correct? > myone.txt > mytwo.txt > mythree.txt or is there any better way? ...

How to list specific type of files in recursive directories in shell?

How can we find specific type of files i.e. doc pdf files present in nested directories. command I tried: $ ls -R | grep .doc but if there is a file name like alok.doc.txt the command will display that too which is obviously not what I want. What command should I use instead? ...

What does "local -a foo" mean in zsh?

Zsh manual mentions that option -a means ALL_EXPORT, ALL_EXPORT (-a, ksh: -a) All parameters subsequently defined are automatically exported. While export makes the variable available to sub-processes, the how can the same variable foo be local? ...

How can I pass a file argument to my bash script using a Terminal command in Linux?

Hello everyone! So my question is how can I pass a file argument to my bash script using a Terminal command in Linux? At the moment I'm trying to make a program in bash that can take a file argument from the Terminal and use it as a variable in my program. For example I run myprogram --file=/path/to/file in Terminal. My Program #!/bin...

Recursively search for files of a given name, and find instances of a particular phrase AND display the path to that file

I have a bunch of folders and subfolders. Each one contains, amongst other things, a text file called index.yml with useful data. I want to search through all of the different index.yml files to find instances of a search string. I must be able to see a few lines of context and the directory of the index.yml file that was found. This...

Is there a way to make Textedit the default editor for text files opened in the terminal?

It there a way to make files opened for editing in the terminal open in Textedit instead? I mean, where a command might open a file for editing (like git commit), instead of opening that file in vi or emacs, it would open in Textedit (or perhaps another Textediting application of you choosing, such as Coda). And as a bonus question, is...

Batch renaming using shell script

I have a folder with files named as input (1).txt input (2).txt input (3).txt ... input (207).txt How do I rename them to input_1.in input_2.in input_3.in ... input_207.in I am trying this for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done But it gives me mv: target `(100).txt' is not a d...

Removing non-displaying characters from a file

$ cat weirdo Lunch now? $ cat weirdo | grep Lunch $ vi weirdo ^@L^@u^@n^@c^@h^@ ^@n^@o^@w^@?^@ I have some files that contain text with some non-printing characters like ^@ which cause my greps to fail (as above). How can I get my grep work? Is there some way that does not require altering the files? ...

What does the ∴ character do in a bash shell?

Stumbled across the ∴ operator in some of the rvm install scripts and couldn't seem to locate information on what it does? Is there documentation on this somewhere? ...

Showing a long running shell process with Apache

I have a CGI script which takes about 1 minute to run. Right now Apache only returns results to the browser once the process has finished. How can I make it show the output like it was run on a terminal? Here is a example which demonstrates the problem. I want to see the numbers 1 to 5 appear as they are printed. ...

How to append something at the end of a certain line of the text

I want to append something at the end of a certain line(have some given character). For example, the text is: Line1: I just want to make clear of the problem Line2: Thanks to all who look into my problem Line3: How to solve the problem? Line4: Thanks to all. Then I want to add "Please help me" at the end of Line2: Thanks to all...

Problem with sh profile in IPython on Mac

I recently heard about profiles in python and quickly discovered the sh profile. I went to invoke it to try it out and got the following error on my Mac running Snow Leopard and the system Python2.6. Anyone else see this before? I was thinking about trying to reinstall the IPython egg to see if it fixed it, but thought I'd ask if any oth...

run shell script from php

Hi Guys, I am attempting to create a php script that can connect thru ssh to my Qnap TS219 server and run a command on it. My script so far connects fine to the server but when I run the command I get an error message and I can't figure it out. exec.sh #!/bin/bash cp /share/MD0_DATA/Qdownload/rapidshare/admin/script.txt /share/MD0_DA...

Select time intervals from log files using Bash

I need to extract some information from a log file using a shell script (bash). A line from the log file usually looks like this: 2009-10-02 15:41:13,796| some information Occasionally, such a line is followed by a few more lines giving details about the event. These additional lines do not have a specific format (in particular they d...

emacs can invoke shell and execute commands-- can they act on Emacs buffers?

I use Alt-! (Alt-Bang) a lot in Emacs. One of the big things I use it for is Alt-! cat $logfile | grep 'this' # show me one kind of event or sometimes Alt-! cat $logfile | grep 'this' | wc -l # count that one event's occurrences Two things: 1) No tab-completion from this prompt: why not? 2) What if instead of $logfile, I want to ...

Is there a free shell service for Mac computers?

Hi, I'm looking for a shell where I can test shellscripts and a programs on a Mac. What I'm looking for, is something like bshellz.net but with Apple computers (i.e. Macs). Is there such thing available? I was googling for the last few days, but I couldn't find anything. ...

ksh + smart test line solution

hi I write the following syntax (part of my ksh script) to check if the first word of LINE=star and the second word is car [[ ` echo $LINE | awk '{print $1}' ` = star ]] && [[ ` echo $LINE | awk '{print $2}' ` = car ]] && print "match" I need other simple smart and shorter solution then my syntax. from awk,perl or sed(if ...

ksh + argument in PARAM

hi is it posible to print the value NUM (100) , while I must use only ' and not " # NUM=100 # PARAM='some text $NUM' # echo $PARAM some text $value the right print some text 100 ...

include(): Failed opening when accessing by Shell/Crontab

I'm setting up a crontab. When accessing the php file directly (domain.com/file-path/file.php) it works perfectly. When accessing it through shell (php -f /var/www/vhosts/domain.com/file-path/file.php) I get include file errors all over the place. It has something to do with the include path being set as: (include_path='.:') Is there an...