Heh, you revived a 3.5 year old thread.
Anyway, everything in that script will work with bourne, except the process substitution. You can use a fifo instead.
#!/bin/sh
somecommand() {
...
Type: Posts; User: geirha; Keyword(s):
Heh, you revived a 3.5 year old thread.
Anyway, everything in that script will work with bourne, except the process substitution. You can use a fifo instead.
#!/bin/sh
somecommand() {
...
I prefer to just do the cd in a subshell.
for dir in ./*/; do
( cd "$dir" && ./script.sh )
done
Is script.sh the same script copied to each directory?
Bash will expand parameter expansions inside double quotes, so it replaces $1 and $2 with the first two arguments of your shell (which are typically empty in an interactive shell). With single quotes...
A couple of example lines from the users_data_file.txt file would help.
Bash already logs your commands for you to ~/.bash_history. By default it doesn't add a timestamp, but you can modify the special HISTTIMEFORMAT variable to achieve that.
E.g. add the following...
It sounds like this could be related to this question in the BashFAQ,
How can I get all lines that are: in both of two files (set intersection) or in only one of two files (set subtraction), so I'll...
You can match start of word and end of word with \< and \>. (A word in this context consists of [A-Za-z0-9_])
$ sed 's/\<usr\>/NEW/g' <<< "%usr% 4usr4 .usr."
%NEW% 4usr4 .NEW.
This syntax...
Check the contents of that /home/devserve/usvn-1.0/files/svn/testproject/hooks/post-commit script. My guess is it uses the absolute path to svn instead of relying on the PATH variable.
Are you running that on Ubuntu? There are several different rename commands, using completely different syntaxes. The default rename command in Ubuntu is perl rename, with which stylishpants' rename...
Aha, in that case this thread's title is misleading. Based on the title on that book, it most likely teaches you to write sh scripts, not bash scripts.
When you omit the in words part, it assumes in "$@". Run help for in an interactive bash shell to see the syntax.
Out of curiosity, which book is it?
find . -type f -name "Track [0-9].mp3" -exec sh -c 'for file; do mv "$file" "${file%[0-9].mp3}0${file##* }"; done' _ {} +
See http://mywiki.wooledge.org/BashFAQ/030 for other approaches.
Here's your logger command written in bash:
logger() {
local prevline line count
while IFS= read -r line; do
if [[ $line = "$prevline" ]]; then
((count++))
...
program 2>&1 | logger
You might want some options for the logger command. See man logger.
Use a for-loop in the BEGIN block.
awk '
BEGIN {
for (t=0;t<100;t++) {
print t, 15.3*...;
}
}'
Ah, right, because 8.04 and 10.04 has different implementations of nc installed by default, and since there is no standard determining the behavior of nc, we happen to have two versions of nc...
Right, then var=$(<"$filename") will do, though since it's just one line, you can also use read. Using read is more efficient, and I also find that "prettier".
read -r var < "$filename"
My best guess is that you run that script with sh instead of bash. Bash's echo takes -e and -n as options, sh's echo does not. Use printf instead or at least make sure you run the script with bash.
...
If you want all files to have the same mode, just run the chmod uncoditionally on all files. If the file already has that mode, nothing happens, if it has a different mode, it gets the new mode.
...
You can't export array variables. I'm not exactly sure how bash handles export var=( something ), but it's pointless anyway, so don't do it. What are you actually trying to do?
For reading the...
pv -fr < A.mkv 2> >(tr '\r' '\n' > foo.txt) | mplayer -msglevel all=1 -
Since pv's output isn't going to a terminal, it'll buffer it though, so you likely won't see any data in foo.txt until it's...
Well, problem is, "give int passwd user" doesn't make any sense, what do you mean? And what do you mean by "Shadow user" and "Group user"?
If you have some sample input and wanted output you...
Your question is not understandable, not to me at least. You'll have to write it in valid english. Perhaps see if there's a Loco team for your language and ask your question there.
...
For adding many users in batch, look into newusers(8).
man 8 newusers
Ah, the closing ;; was missing. I completely missed that.
Though, the TLDP bash guides are outdated and littered with bad practice as usual. Parsing df -h output, piping together awk and grep,...