shell

cp command should ignore some files

Sometimes I need to perform following command cp -rv demo demo_bkp However I want to ignore all the files in directory .git . How do I achieve that? It takes a long time to copy .git files and I do not need those files. ...

How does the shell know which directory it's in?

I have been trying to figure out how a shell knows which directory you're currently in. I know there is an environment variable $PWD but when I try changing it manually, it changes what my shell shows at the prompt but commands like ls and cd are unaffected. cd is an internal shell command so I can understand it might use info stored wi...

How to create a CLI program with "shell prompt"?

Hi, I'm very new in programming. The following task looks very simple but I don't know how to do it. Appreciate if anyone can give me some guidance. I'm using Linux OS. I would like to create a CLI program and let the user run it in shell terminal. I plan to use Bash shell script to create this program, but C++ or Perl should be ok too...

Bash script for searching and replacing tags.

I have a file have lots of string tags like </usr/share/some_pattern>, all they have in common is they all begin with a < and end with a >, how can write a bash script to remove all these tags(including the strings inside)? ...

How to shave off last character using sed?

That is, going from ABCD -> ABC ...

How to define environment variable in input command of su

This command has an empty output. su user -c "ABC=abc;echo $ABC" Any idea, how can I define a variable in the input command? ...

Only get hash value using md5sum (without filename)

I use md5sum to generate a hash value for a file. But i only need to receive the hash value, not the file name. md5=`md5sum ${my_iso_file}` echo ${md5} 3abb17b66815bc7946cefe727737d295 ./iso/somefile.iso How can i 'strip' the file name and only remain the value ? ...

Mac-Automator, How to pipe the output of a shell script to a GUI text box

Hi, the problem i face is this: I would like to have in a context menu (when i right-click on a folder) an action to be executed and display the output to the user, inside, let's say, a text area window with a vertical scrolling bar. Suppose, that the action is just a shell script that executes a "find" command inside the given directo...

Linux crontab doesnt launch a script

I have this user crontab (accessed via the command crontab -e): # m h dom mon dow command */3 * * * * sh /home/FRAPS/Desktop/cronCheck.sh The script cronCheck.sh looks like that: #!/bin/sh SERVICE='Script' if ps ax | grep -v grep | grep -i "$SERVICE" > /dev/null then echo "######## $SERVICE service running, everythin...

Bourne Shell Building and referencing a variable

I have a shell that runs where the preset env variables include: FOOCOUNT=4 FOO_0=John FOO_1=Barry FOO_2=Lenny FOO_3=Samuel I can not change the way I get this data. I want to run a loop that generates up the variable and uses the contents. echo "Hello $FOO_count" This syntax is however wrong and that is what I am searching for......

Suppressing diffs for deleted files in git

Hi all, I want to get a quick overview of the local changes in my repository, but I don't want a diff that shows deleted files, since every single line is a minus. Basically, I want something like 'git diff HEAD <list of modified files only>'. In an ideal world, it would be preceded by the list of deleted and added files, but not show ...

Running R inside a buffer in Vim

I have used Stata and gVim on Windows for a while now. Recently I have switched to Linux, and I am planning to also change from Stata to R. A friend of mine is using R and Emacs ESS which seems to work perfect, however i'd rather like to keep using vim. I have installed the vim-r-plugin2, however, i can only send code to a seperate term...

Extract IP from netstat output

The netstat output contains thing like... tcp 0 0 0.0.0.0:80 221.126.149.99:51973 ESTABLISHED 23879/apache2 tcp 0 0 0.0.0.0:80 66.249.68.154:40883 ESTABLISHED 23899/apache2 tcp 0 0 0.0.0.0:80 66.249.68.81:41200 ESTABLISHED 23892/apache2 tcp 0 0 0.0.0.0:80 ...

Free Unix Shell with open port ?

Hi,I'm in a restricted network,that way I'm looking for a free Unix shell with open port to use SSH tunnelling (remote port forwarding) and thanks. ...

all shell-script commands in batch-commands portable?

hi, I'm no linux user (yes, I'm sorry!) and a friend of mine asked me to port his shell script for linux into a batch for windows, because he wants to do the same task there to. I haven't worked with shell-scrips before and my batch skills are, hmmm, almost not existing, but I would like to try that. So I would like to ask if there ar...

rsync option in a variable

Hi, I want to put command option of rsync into a variable so I can reuse it for other rsync commands. Here is what I tried but it didn't work. roption="-a --recursive --progress --exclude='class' --delete --exclude='exclude' --exclude='.svn' --exclude='.metadata' --exclude='*.class'" rsync "$roption" /media/CORSAIR/workspace ~/ Can a...

Ruby gems for user interaction in the shell?

I wonder if there are Ruby gems for user interaction in the shell similar to the Thor::Actions. Maybe more extensive. ...

Csh run script config file, and variables.

I am fairly inexperienced with shell(csh in this case) scripts but was asked to edit one. I was asked to add a config file to make it much simpler to edit several specific variables. I thought this was silly because this is a script and reading to and from a file would be a little silly so I though I could just make a different script th...

set filename tab-completion in dash case insensitive

I’m using dash shell filename tab-completion feature to complete file names.However default tab-completion in dash case-sensitive.How can I force filename tab-completion in dash case insensitive? In bash, I can add "set completion-ignore-case on" to /etc/inputrc, however it makes no effects in dash. Any suggestions? ...

How to detect using of wildcard (asterisk *) as parameter for shell script?

In my script, how can I distinguish when the asterisk wildcard character was used instead of strongly typed parameters? This # myscript * from this # myscript p1 p2 p3 ... (where parameters are unknown number) ...