How to join multiple lines of filenames into one with custom delimiter
paste -s -d joins lines with a delimiter (e.g. “,”), and does not leave a trailing delimiter: ls -1 | paste -sd “,” –
paste -s -d joins lines with a delimiter (e.g. “,”), and does not leave a trailing delimiter: ls -1 | paste -sd “,” –
Solution 1: Using process substitution The most convenient way of doing this is by using process substitution. In bash the syntax looks as follows: foo -o >(other_command) (Note that this is a bashism. There’s similar solutions for other shells, but bottom line is that it’s not portable.) Solution 2: Using named pipes explicitly You can … Read more
Info/Summary With bash scripting you can enclose commands in back ticks or parantheses. This works great for labling files, the following wil create a file name with the date appended to it. Methods Backticks – $ echo myfilename-“`date +”%d-%m-%Y”`” $(parantheses) – : $ echo myfilename-$(date +”%d-%m-%Y”) Example Usage: echo “Hello World” > “/tmp/hello-$(date +”%d-%m-%Y”).txt” (creates … Read more
In GDB 7.2: (gdb) help info proc Show /proc process information about any running process. Specify any process id, or use the program being debugged by default. Specify any of the following keywords for detailed info: mappings — list of mapped memory regions. stat — list a bunch of random process info. status — list … Read more
I’ve done something similar using the inotifywait tool: #!/bin/bash while true; do inotifywait -e modify,create,delete -r /path/to/your/dir && \ <some command to execute when a file event is recorded> done This will setup recursive directory watches on the entire tree and allow you to execute a command when something changes. If you just want to … Read more
Probably something like # ~/.inputrc “\e[A”: history-search-backward “\e[B”: history-search-forward or equivalently, # ~/.bashrc if [[ $- == *i* ]] then bind ‘”\e[A”: history-search-backward’ bind ‘”\e[B”: history-search-forward’ fi (the if statement checks for interactive mode) Normally, Up and Down are bound to the Readline functions previous-history and next-history respectively. I prefer to bind PgUp/PgDn to these … Read more
If you use bash and have the extglob shell option set (which is usually the case): mv ~/Linux/Old/!(Tux.png) ~/Linux/New/
You can’t do this with cp alone but you can combine cp with xargs: echo dir1 dir2 dir3 | xargs -n 1 cp file1 Will copy file1 to dir1, dir2, and dir3. xargs will call cp 3 times to do this, see the man page for xargs for details.
Try: my_command || { echo ‘my_command failed’ ; exit 1; } Four changes: Change && to || Use { } in place of ( ) Introduce ; after exit and spaces after { and before } Since you want to print the message and exit only when the command fails ( exits with non-zero value) … Read more
No. From the cron man page: …cron will then examine the modification time on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified But if you just want to make sure its done anyway, sudo service cron reload or /etc/init.d/cron reload