I want to run a script in unix that will look for a specific pattern inside a passed argument. The argument is a single word, in all cases. I cannot use grep, as grep only works on searching through files. Is there a better unix command out there that can help me?
...
Why is that some commands require the echo statement but others can simply be written without:
#!/bin/bash
aptitude upgrade
echo "mysql-server-5.1 mysql-server/root_password password $DB_PASSWORD" | debconf-set-selections
...
I have some lines stored in a text file called bashrc_snippet. I would like to insert them into .bashrc. Since I sometimes change the contents of the text file I would like to be able to re-insert them in the .bashrc-file. To do this I want to use marker lines:
# User things
HISTSIZE=1000
#START
alias ls='ls --color=tty'
... some more ...
The main question here is: is there a standard method of writing UNIX shell scripts that will run on multiple UNIX platforms.
For example, we have many hosts running different flavours of UNIX (Solaris, Linux) and at different versions all with slightly different file system layouts. Some hosts have whoami in /usr/local/gnu/bin/, and ...
I try
echo 10**2
it prints 10**2. How to make it work?
...
I want to write a bash script which takes 2 arguments, a and b. Based on the argument, it writes in section a or section b of a text file.
Output file is a txt file something like this:
common content....
section a:
<everything should be written here when I specify option "a">
section b:
<everything should be written here when I specif...
Hi
New to bash scripting, I'm writing a script to copy my TV shows accross from a download folder to an archive folder.
So far I have this:
find `*`show1`*`.avi | cp \"" $0 "\" "/mnt/main/data/tv/Show1"
find `*`show2`*`.avi | cp \"" $0 "\" "/mnt/main/data/tv/Show2"
I understand this is not the best method, but my skills of bash ...
Hi, I have a bash function that is called must be called by an EXIT trap after the first time that it is called. The function sets the trap again to fire as soon as the function exits.
echo 0 > .i
function launchNextExperiment
{
( # Run in nested subshell
# Implement a mutex lock, not shown
j=`cat .i`
if [ $j -lt $k ]
then
t...
Hi, I have a bash script with some scp commands inside.
It works very well but, if I try to redirect my stdout with "./myscript.sh >log", only my explicit echos are shown in the "log" file.
The scp output is missing.
if $C_SFTP; then
scp -r $C_SFTP_USER@$C_SFTP_HOST:$C_SOURCE "$C_TMPDIR"
fi
Ok, what should I do now?
Thank you
...
I have a bash script with a code like this:
echo "EXECUTING TASK 1"
sort -r scripts/sh/test-list | while read fn; do
sh -vx scripts/sh/test-web-task.sh "$fn"
done
echo "EXECUTING TASK 2"
sort -r scripts/sh/test-unit-list | while read fn; do
sh -vx scripts/sh/test-unit-task.sh "$fn"
done
In test-web-task and test-unit-t...
I have a "Data" directory, that I rsync to a remote NAS periodically via a shell script.
However, I'd like to make this more efficient. I'd like to detect if something has changed in "Data" before running rsync. This is so that I don't wake up the drives on the NAS unnecessarily.
I was thinking of modifying the shell script to get the ...
Example of usage (contrived!): rename .mp3 files to .txt.
I'd like to be able to do something like
find -name '*.mp3' -print0 | xargs -0 -I'file' mv file ${file%.mp3}.txt
This doesn't work, so I've resorted to piping find's output through sed -e 's/.mp3//g', which does the trick.
Seems a bit hackish though; is there a way to use the...
I've just added a .profile to my bash shell. However, I've noticed the error "-bash: print: commant not found" keeps on appearing even if you are changing to a valid directory. My .profile just contains a few exports.
[rob@mypc:/home/rob]cd apps
-bash: print: command not found
[rob@mypc:/home/rob/apps]cd util
-bash: print: command not ...
Is it possible to know the pid of the iwevent process in the following bash script:
#!/bin/sh
( iwevent | logger -t IWEVENT ) &
echo the pid is: ???
Note that iwevent run until ctrl-c signal.
FYI.
I run this script in a /etc/network/interfaces "up" statement and I want to kill the running iwevent process in the related "down" stateme...
Purpose:
change names of all files in a directory to random strings of the same length
list this files in another file (with a possibility to make from it sql query )
I think bash would be great for it, but I have no idea how to do this, can you help me?
...
Hi, I have a task where I need to move a bunch of files from one directory to another. I need move all files with the same file name (i.e. blah.pdf, blah.txt, blah.html, etc...) at the same time, and I can move a set of these every four minutes. I had a short bash script to just move a single file at a time at these intervals, but the ne...
Hi,
I'm pretty new to bash, but I have the following script that does a simple operation: copying a folder.
In shell, I would type sudo macaco NewFolder
and this is the bash script:
#!/bin/bash
wwwPATH="/var/www"
bitMotorVERSION="0.0.0"
targetDir="$wwwPATH/$1"
cp -r /var/fw/bitMotor/$bitMotorVERSION/ $targetDir
This works fine! No...
I try to build a little script to start my development environment. For that task I try to open a gnome terminal with several tabs where automatically the rails server and autotest is started.
But
gnome-terminal --tab -e "rails server" --tab --tab
does not work ("error creating the child process").
Also
gnome-terminal --tab -e "ba...
I currently have something of the form
abc=`find ~/$folder .. etc
I'd like to know how to get the number of items in abc:
abc_length = ?
Thanks
...
In setting up my personal Linux command line development environment, I want to use term inside emacs b/c then I can switch to 'line mode' and copy/paste the output into any other buffer.
However, when I run mysql inside term inside emacs, the pretty sql tables still word wrap according to the width of that emacs window :(. I was hoping...