shell

Are Bash and Linux shell the same?

I often getting confused with bash and shell. Are they same? If I want to learn the bash, will it be covered with Linux shell programming related books? I use Ubuntu Linux. Edit: (Added after getting two answers.) How bash is associated with terminal? ...

Defining erlang functions in the shell

Is there any way to define an Erlang function from within the Erlang shell instead of from an erl file? ...

diff'ing diffs with diff?

I need to know if the two patches are effectively the same. I have an old patch file and new patch file created with the unix diff command. Just diff'ing the patches reports differences due to the timestamp when the patch was created. Is there a way (with diff?) that can reliably tell me if the two patches are effectively the same? ...

Write shell script that can only be run by a sudo user in Ubuntu

I'm writing a shell script that is supposed to be run by users only in sudo user list, what's the appropriate way of doing this? what I'm thinking is in the shell script, try to create a dummy file in system dir such as /var/run/ and remove it, so users not in sudo list will receive a permission error, but I believe there gotta be a mo...

How do I protect a shell script from being downloaded?

I have a shell script which is called by a cron job. I don't want it to be downloaded via a browser. I have tried the filesmatch htaccess directive but that doesn't seem to stop me calling the url of the file and downloading it. How can I protect it? ...

Python/Django shell won't start

One of the great features of Django is that you can open a python interpreter set-up for use with your project. This can be used to analyse objects in a database and allows any python commands to be executed on your project. I find it essential for Django development. It is invoked in the project directory using this command: $ python m...

shell script filter question

I am trying to store the resulting list from "ls -la" into a variable then filter out some files name, after that print out only the filtered file names (along with the date and stuff like how ls -la does it" again, but when I do that everything is in one line, is there a way to make sure every file name are on different lines? thanks i...

How do I read a given number of lines from the end of the file using streams in C++?

For my implementation of tail shell command in Linux, I need to read certain amount of lines/bytes from the end of the file using stream input/output. Does anyone have suggestions how to do that? I suspect I need to open a file and pass some parameter to the ifstream constructor, but I don't know what exactly. Googling didn't find anythi...

VCS independent diff

Instead of running "svn diff", "hg diff" and so on .. can we write a single command that calls svn/hg/git accordingly? Can the diff output be made pretty? edit: command-line tools (not GUI) preferred. ...

${HTTPD-...} Perl syntax

Ok, I can't figure this out from reading Perl's documentation. I'm looking at the RHEL4 init script for Apache... What does this line of code do? httpd=${HTTPD-/usr/sbin/httpd} Why not just httpd=/usr/sbin/httpd? What's up with all the extra syntax? -Geoffrey Lee ...

How can I create 1000 files that I can use to test a script?

I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me. ...

Best way to modify a file when using pipes?

I often have shell programming tasks where I run into this pattern: cat file | some_script > file This is unsafe - cat may not have read in the entire file before some_script starts writing to it. I don't really want to write the result to a temporary file (its slow, and I don't want the added complication of thinking up a unique new ...

shell script to remove selected directories

hi i have bunch of dirs , say *a, b, c0, d, Z , foo, * and so on. I want to remove all the directories except dirs foo, foo2, a and b can anyone provide me the syntax to do this shell? Thanks UPDATE I just want to say Thank you to all of you for your responses! ...

How to modfiy environment.rb through sh script? (i.e. modify line in file through script?)

I'm trying to write a sh script to make a rails apps, however due to different conflict, I need to modify my environment.rb file to comment out the rails version. So my question is how do I had '#' to line 8 of environment.rb? ...

Bourne Shell For i in (seq)

I want to write a loop in bourne shell which iterates a specific set of numbers. Normally I would use seq for i in `seq 1 10 15 20` #do stuff loop But seemingly on this Solaris box seq does not exist. Can anyone help by providing another solution to iterating a list of numbers? Thanks, Chris ...

Remove line breaks in Bourne Shell from variable

In bourne shell I have the following: VALUES=`some command that returns multiple line values` echo $VALUES Looks like: "ONE" "TWO" "THREE" "FOUR" I would like it to look like: "ONE" "TWO" "THREE" "FOUR" Can anyone help? ...

how many characters are there in line in a console?

How can I find out how may character are there in a line before the end line in an interactive shell using python? (Usually 80) ...

How to get the name of the current git branch into a variable in a shell script?

I am new to shell scripting and can't figure this out. If you are unfamiliar, the command git branch returns something like * develop master , where the asterisk marks the currently checked out branch. When I run the following in the terminal: git branch | grep "*" I get: * develop as expected. However, when I run test=$(gi...

java Runtime.getRunTime().exec & wildcards?

i'm trying to remove junk files by using Process p = Runtime.getRuntime().exec(); it works fine as long as i do not use wildcards, i.e. this works: Process p = Runtime.getRuntime().exec("/bin/rm -f specificJunkFile.java"); while the following throws back "No such file or directory": Process p = Runtime.getRuntime().exec("/bin/rm -...

What are all of the well-known virtual folder GUIDs?

There seem to be a few virtual folders which have GUIDs associated to them (control panel, desktop) - ::{00021400-0000-0000-c000-000000000046} // desktop Where the blazes are these defined? When are they used? What I want is a way to have a string which represents a virtual folder without any ambiguity. If, for instance, I were to...