Bash scripting does my head in. I have searched for regex assignment, but not really finding answers I understand.
I have files in a directory. I need to loop through the files and check if they fit certain criteria. File names under a certain sequence need to have their sequence increased. Those over a certain sequence need to trigger ...
Is there any way to change the following string so I don't get any problems when there are files/folders with spaces in them?
files=`find ~/$folder -name "*@*" -type f`
I'd prefer if there was a solution that wouldn't have to involve having to change other parts of my code but this line of code, as everything seems to be working corre...
I reckon that the handle $@ in a shell script is an array of all arguments given to the script. Is this true?
i ask, because i normally use search engines to gather information, but I cant google for $@ and I have grewn too custom to easily getting served everything.
...
Hi,
I am looking for a way to get the primary and secondary NS records of a given domain name, and the IP addresses associated with it. Which means that I am looking for these:
dns1:
ip1:
dns2:
ip2:
Now this kind of information is available from websites like intodns.com, but I am working on a huge list of domains and would like to aut...
I've been trying to get a shell(bash) script to insert a row into a REMOTE database, but i've been having some trouble :(
The script is meant to upload a file to a server, get a URL,HASH, and a filesize, connect to a remote mysql database, and insert the data into an existing table. I've gotten it working until the remote MYSQL database...
I have thousands of files without extensions after recovery (mostly pictures). I need to sort them into separate folders by filetype (folders must be created during sort process). I can determine filetype in linux using "file" command. Does somebody have bash script for it?
For example: Initial dir contains files: 001, 002, 003, 004. A...
I would like to echo text and also remotely ping a computer and have the output be sent to a log file. I also need to do this in parallel but I am having some trouble with how the output is being sent into the log file.
I would like the output to look like:
host | hostTo | result of ping command
but since I have this running as a back...
How can I join all of the files in a directory. I can do it in one step by explicitly naming the files below, is there a way to do it without explicitly naming the files?
join <(\
join <(\
join <(\
join\
<(sort ${rpkmDir}/HS0477.chsn.rpkm)\
<(sort ${rpkmDir}/HS0428.chsn.rpkm) )\
<(sort ${rpkmDir}/HS0419.chsn.rpkm) )\
<(sort ${rpkmDir}/...
I have the following bash script
for s in $(ls -1 fig/*.py); do
name=`basename $s .py`
if [ -e "fig/$name.pdf" -o "fig/$name.pdf" -ot "fig/$name.data" -ot "fig/$name.py" ]; then
$s
fi
done
It is supposed to invoke a python script if the output pdf does not exist, or the pdf is older than the py or data file.
Unfortunal...
i have the following case :-
i design :-
1- file.bat on windows 2003
2- file2.sh on unix-aix
file2.bash call file.bat and file.bat receve path from file2.bash and file.bash return a value to file2.bat .... when i execute this from my servers all thing good
but when i call this from my website (PHP) the following error appear :-
ER...
Hi,
I'm trying to pass the value of a cookie to a bash script:
RewriteCond %{HTTP_COOKIE} mycookie=(.*) [NC]
RewriteRule .* script.sh?cookievar=%1
... but can't seem to find out how to read the GET variable in the bash script. (I suppose I'm asking Google the wrong queries, but can't find any info on this).
Is this even possible, an...
Major bash-noob here. Writing my second program again. For my homework, I need to write a number of grep statements using regexps.
This is the first one I'm trying to write.
I'm saving it as grep.bash:
#!/bin/bash
egrep bright_side_of_life 'the'
The error I get is :
egrep: the: no such file or directory
...
One of my homework questions is to search using grep an lines that contain the word 'death' or 'breath'.
I know the [] operator acts as an or, but how do I use it to specify 'd' or 'br' ?
This won't work:
egrep [dbr]eath test_file
...
Tried to set some aliases in my .bashrc file. This one...
export alias umusic="/Volumes/180 gram/Uncompressed/"
...gets the following error...
-bash: cd: /Volumes/180: No such file or directory
...when I try "cd $umusic".
I've tried various methods of escaping that whitespace in the directory name, to no avail. (180\ gram, 180%...
I have a bash script that runs on a machine (called lazyguy) that is usually turned off. Every night, lazyguy wakes up at a known time programmed in the BIOS, does a bunch of processing and inserts data to its Postgres database. Then, it goes to sleep (database and all).
How can get notified when the script did NOT run? Ideally, I'd ...
I'm just trying my hand in bash, so I wrote a simple program in C to count the number of characters in a file.
This is my C program:
#include <stdio.h>
int main()
{
int i, nc;
nc = 0;
i = getchar();
while (i!=EOF){
nc = nc + 1;
i = getchar();
}
printf("%d\n",nc);
return 0;
}
This is the bash command I'm using ...
Hi all !
(Sorry for the confusion. Previous $ sign occurred when I tried to simplify the actual problem. Thanks for correcting the question)
I wanted to split a directory name on underscores (ex: dir_to_split="my_test_dir") like this:
my_dir=($dir_to_split)
var=$(echo $my_dir | awk -F"_" '{print $1,$2,$3}')
set -- $var
splited_1=...
Question: is there a simple sh/bash/zsh/fish/... command to print the absolute path of whichever file I feed it?
Usage case: I'm in directory /a/b and I'd like to print the full path to file c on the command-line so that I can easily paste it into another program: /a/b/c. Simple, yet a little program to do this could probably save me 5 ...
I have written the following two functions in Bash:
function prepend_path() { PATH=$1:$PATH }
function prepend_manpath() { MANPATH=$1:$MANPATH }
The bodies of the functions are actually going to be more complicated. To avoid code duplication, I would like to do something like the following:
function prepend() { "$1"=$2:"$1" }
functio...
hi
the following script.bin append by tee lines to file.log (from my bash script)
IP=xxx.xxx.xxx.xxx
./script.bin | tee -a file.log
my target is to add the "IP=127.0.0.1" after each line that created by tee
(the IP address is example)
remark: we can't modify the script.bin in order to add the "IP=127.0.0.1" -because its binary...