i have a folder with many different types of files...but i want to create a symbolic link of only files that are of a certain file type (the data files with extension *.txt.mrg) in this case...i want to have the same file names for the symbolic links as the original files...how do i do this? i want to be able to create all the symbolic l...
Let's say I have defined a function abc() that will handle all the logic related to analising the arguments passed to my script.
How can I pass all arguments my bash script has received to it? The number of params is variable, so I can't just hardcode the arguments passed like this:
abc $1 $2 $3 $4
edit: Better yet, is there any way ...
I've thousands of png files which I like to make smaller with pngcrush. I've a simple find .. -exec job, but it's sequential. My machine has quite some resources and I'd make this in parallel.
The operation to be performed on every png is:
pngcrush input output && mv output input
Ideally I can specify the maximum number of parallel o...
Why doesn't this print all the passed arguments, in bash?
function abc() {
echo "$1" #prints the correct argument
for x in `seq 1 $#`; do
echo "$x" #doesn't print the 1st, 2nd, etc arguments, but instead 1, 2, ..
done
}
It is printing
1
2
3
4
...
instead.
...
I am using Console2 as a bash wrapper on Windows. Most importantly, it enables me to start up a new bash tab in a predefined project directory.
Now I would like to replace the Windows command line by a Cygwin bash. However, the "Startup Dir" setting in Console2 is not respected by Cygwin.
Basically, I see three solution approaches:
F...
Hi there,
I need to create a list of files which are located on my hard disk in order of when they arrived on the hard disk. To do so, I have used the following:
ls -lat
which lists all the files in date/time order, however, it only orders them to the nearest second. The problem here is that there are thousands of files and every so...
my script=
#!/bin/bash
echo ************************BEGIN LOG******************************>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
date +"%m/%d/%Y %H:%M:%S $HOSTNAME">>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
ruby /root/backup_scripts/new_scripts/aapxen01.rb>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
rub...
The default shell on the the system is csh but I want to write a script in bash. How do I write a script that will run bash and then convert back to csh at the end.
I tried this but it doesn't work:
bash
var=Hello
echo $var
csh
...
I am writing a bash shell script, run where the user is expected to pass a path into it as the $1 variable. How can I determine if $1 is missing and define a default value instead for it?
...
How do I remove certain files from a different directory than $PWD using the bash shell script.
Looking at the documentation for rm, it appears that rm only works in $PWD.
Am I forced to use this method:
oDir=$PWD
cd directorytoremovefiles
rm files
cd oDir
...
So, I have a bash script inside of which I'd like to have a conditional which depends on what a perl script returns. The idea behind my code is as follows:
for i in $(ls); do
if $(perl -e "if (\$i =~ /^.*(bleh|blah|bluh)/) {print 'true';}"); then
echo $i;
fi;
done
Currently, this always returns true, and when I tried it ...
How could I read the content of a parent folder and if sub-folders are found, then make a tar.gz files of those subfolders found. However, I know that subfolders will have the following filename format: name-1.2.3 What I want is to create a tar.gz file that looks like: name-1.2.3-20100928.tar.gz Any help will be appreciated.
...
I am trying to create nested array's dynamically from a string that has been parsed (parameter expansion) using a for loop in bash and I am failing:
user@server:/home/user> foo=one,two,three
user@server:/home/user> for i in ${foo//,/" "}; do echo ${i}; done
one
two
three
user@server:/home/user> for i in ${foo//,/" "}; do declare -a ${i}...
I have bash script that I use regularly in my job to automate a large job. I was making some changes today, but everything seemed fine. The script itself is about 1700 lines long. The first part of the script is all good and runs through all the user input and logic just fine. It then proceeds into the core of the script and stops wo...
Hello,
I need to copy data from one database into my own database, because i want to run it as a daily cronjob i prefer to have it in bash. I also need to store the values in variables so i can run various checks/validations on the values. This is what i got so far:
echo "SELECT * FROM table WHERE value='ABC' AND value2 IS NULL ORDER B...
Hi dear stackers,
I created a script that starts all the apps I need for my day and assign them to the workspaces I want.
Given I'm a extreme-lazy basterd, I'd like to know is there was a way to pass an argument to the terminal I open. The argument would be an alias that runs a massive source update of all the projects I'm working on....
I have a couple of scripts to control some applications (start/stop/list/etc). Currently my "stop" script just sends an interrupt signal to an application, but I'd like to have more feedback about what application does when it is shutting down. Ideally, I'd like to start tailing its log, then send an interrupt signal and then keep tailin...
Hi,
I have several hosts from which i want to do the same query. So imagine, i have on each server the database db and a table test like :
mysql> desc test;
+-------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
...
I am a noob in shell-scripting. I want to print a message and exit my script if a command fails. I've tried :
my_command && (echo 'my_command failed; exit)
but it does not work. It keeps executing the instructions following this line in the script. I'm using Ubuntu and bash.
Thanks all.
...