I want to dump my MySQL database and make daily backups with rsync. First approach I came up with is something like mysqldump -ufoo -pbar baz > /var/tmp/baz.sql && rsync /var/tmp/baz.sql /backup/ && rm /var/tmp/baz.sql. Then I started to wonder if it is possible not to use the temporary fil…
Tag: shell
comparing two files with different columns
i have the two files(count.txt, count1.txt). i need to do the following 1. get the values from count.txt and count1.txt where 1st column is equal. 2. if its equal need to compare the 2nd column like ((1st column value + 5) >= 2 column value) count.txt order1,150 order2,165 order3,125 count1.txt order1,155 …
How to rename all files in a folder removing everything after space character in linux?
Hello I can’t use well the regular expressions it’s all day I’m searching on Internet. I have a folder with many pictures: 50912000 Bicchiere.jpg 50913714 Sottobottiglia Bernini.jpg I’m using Mac OS X, but I can also try on a Ubuntu, I would like to make a script for bash to remove all…
Bash script processing limited number of commands in parallel
I have a bash script that looks like this: But processing each line until the command is finished then moving to the next one is very time consuming, I want to process for instance 20 lines at once then when they’re finished another 20 lines are processed. I thought of wget LINK1 >/dev/null 2>&…
How to copy directories into a directory using install in bash?
Assume the nested directories foo/bar and a empty directory dest. I would like to call something like install foo dest such that dest contains the directory foo/bar. I have tried the following: install foo dest => install: omitting directory “foo” install -d foo dest => nothing happens Answe…
How to attach ttyS to screen and capture it simultaneously
For capturing ssh sessions I use “script” command: “script -c ‘ssh user@host’ outfile”. But I have no idea how to capture sessions to remote hosts, that connected over com(serial) port. ends immediately with empty log. Both 2 functions that implemented in screen is necessar…
Continuously monitor a directory in linux and notify when a new file is available
I’m a starter in Linux and scripting environment. My requirement is like this: From an asp.net application, a file will be generated and copied to a predefined folder on a Linux server machine. (I’m assuming this can be done by remote file sharing using samba server) A service or script or whateve…
How to start java program with hidden terminal
How can i create shell script for linux, Which will start my java program and then exit itself Like:- create new process with no terminal-> java “Test”. exit terminal itself. i have tried with Fork and exec but i couldn’t get any of it please help me Answer I solved this by using Python s…
Backspace in zsh fails to work in quite the strange way
I’m on a fresh Virtualbox install of CentOS 6.4. After installing zsh 5.0.2 from source using ./configure –prefix=/usr && make && make install and setting it as the shell with chsh -s /usr/bin/zsh, everything is good. Then some time after, after installing python it seems, it start…
How do I replace single quotes with another character in sed?
I have a flat file where I have multiple occurrences of strings that contains single quote, e.g. hari’s and leader’s. I want to replace all occurrences of the single quote with space, i.e. all occurences of hari’s to hari s all occurences of leader’s to leader s I tried and but they ar…