bash

remove an ACL entry for just ONE user in MacOS? oddly difficult

I'm trying to remove an ACL set for johndoe from all the folders recursively on one of my drives without hosing any other entries! Anyone know how to do this without affecting the ACLs that already exist for other groups/users? I'm looking for the Mac equivalent of "setfacl -d u:johndoe" I know you can use chmod to remove a rule from m...

Encoding Keyboard Command Onto Bash Script

Dear all, I have the following way to submit a job with cluster using qsub: Submitting jobs from standard input To submit a PBS job by typing job specifications at the command line, the user types qsub [options] <return> then types any directives, then any tasks, followed by (in UNIX) C...

number of tokens in bash variable

how can I know the number of tokens in a bash variabe (whitespace separated tokens) - or at least, wether it is one or there are more. ...

How do I tell if a file does not exist in bash?

I've used the following script to see if a file exists: #!/bin/bash FILE=$1 if [ -f $FILE ]; then echo "File $FILE exists." else echo "File $FILE does not exist." fi What's the correct syntax to use if I only want to check if the file does not exist? #!/bin/bash FILE=$1 if [ $FILE does not exist ]; then echo "File $FILE do...

What is the best way to do string manipulation in a shell script?

I have a path as a string in a shell-script, could be absolute or relative: /usr/userName/config.cfg or ../config.cfg I want to extract the file name (part after the last /, so in this case: "config.cfg") I figure the best way to do this is with some simple regex? Is this correct? Should or should I use sed or awk instead? Shell...

Unable search names which contain three 7s in random order by AWK/Python/Bash

I need to find names which contain three number 7 in the random order. My attempt We need to find first names which do not contain seven ls | grep [^7] Then, we could remove these matches from the whole space ls [remove] ls | grep [^7] The problem in my pseudo-code starts to repeat itself quickly. How can you find the names whic...

Bash command to write the contents of multiple files into a single file

I'm wondering what's the best way to combine multiple .html files (spread across many folders) into one single html file. If someone could create a simple bash command that would be fantastic. (This is a workaround so I can use firebug's command line API to effectively search an entire site for html selector combinations. As far as I kno...

Can you prevent a command from going into the bash shell command history?

Is there a way to prevent a command from being added to the bash shell's command history? I would like to be able to prevent certain "dangerous" commands from being added to the history, such as "rm -rf ~/some/dir", so that it is not accessible to me by pressing the up-arrow to reach previous commands. In this way, it would not be poss...

redirect the stdin to come from a different terminal using Bash

Hello. I'm wondering how one would go about redirecting the stdin of a script from the current xterm session i.e. /dev/pts/0 to one that is also running i.e /dev/pts/1 using bash? I have a bash script that opens 3 xterm windows and I want to get input from only one of those windows and I cannot figure out how to do it. Any help is apprec...

Ruby: In unix find if user who executed the program is root

Hi, I'm writing a rake script and would like to detect (using Ruby rather than bash if possible) if the user who executed the rake script has root privileges. If it is not root then I would like to terminate the script. Regards, Chris ...

How to get all matches from regex?

Hi, I would like to get all occurrences of [0-9A-Z]+? for processing later. I do have if [[ `cat file` =~ '[0-9A-Z]+?' ]]; then echo $BASH_REMATCH; fi Which gives me first match, but how could I process all the matches in the file? Thank you ...

Problem scripting a HTML header request with netcat

I'm trying to play around with netcat to learn more about how HTTP works. I'd like to script some of it in bash or Perl, but I've hit upon a stumbling block early on in my testing. If I run netcat straight from the prompt and type in a HEAD request, it works and I receive the headers for the web server I'm probing. This works: [...

Where to find example source code for a very simple linux shell

This would be great for educational purposes. Also a tutorial on subject would be nice. ...

How do I sum together file sizes in bash, grouping together the results by date?

On a Linux server that I work with, a process writes randomly-named files at random intervals. Here's a small sample, showing the file size, modification date & time, and file name: 27659 2009-03-09 17:24 APP14452.log 0 2009-03-09 17:24 vim14436.log 20 2009-03-09 17:24 jgU14406.log 15078 2009-03-10 08:06 ySh14450....

Bash: Sleep until a specific time/date

I want my bash-script to sleep until a specific time. So I want a command like "sleep" which takes no interval but a end-time and sleeps until then. The "at"-deamon is no solution as I need to block a running script until a date/time. Is there such a command? ...

Distributing loadable builtin bash modules

I've written a built-in for bash which modifies the 'cd' command, a requirement for my software. Is there a way to actually distribute a loadable independently of bash itself? I'd ideally like to distribute just a drop in "additional feature" because I know people can be put off by patching and compiling their shell from source code. ...

How to run a bash script from C++ program

Bash scripts are very useful and can save a lot of programming time. So how do you start a bash script in a C++ program? Also if you know how to make user become the super-user that would be nice also. Thanks! ...

Shell script - Two for loops and changing extension of file

Hello all, I have this Shell script and I've managed to muck it up and I was hoping I could be corrected and put on the right path and hopefully add a few things that I am not competent enough to do myself. I have put what I want do as comments in the Shell script below. #!/bin/bash #Get all files from dir "videos" and send to processL...

Why does this bash script require me to press enter to continue?

Hello all, I was kindly helped a few minutes ago by a user named Juliano and the script works fine but it just baffles me why it continues to work when I press enter, if I don't it just sits there untill I have to keep pressing enter. I thought that was the job of the for loop? #!/bin/bash TIMEFORMAT=%6R for file in /home/t...

BASH ^word^replacement^ on all matches?

To clarify, I am looking for a way to perform a global search and replace on the previous command used. ^word^replacement^ only seems to replace the first match. A quick check through a BASH history cheat sheet doesn't reveal anything. Is there some set option that is eluding me? Mainly curious... Thanks ...