I’m trying to write a script used on a buffer box that does full packet capture of network traffic. As it’s for a fairly big network we split the captures into 100MB segments. At times of high network traffic oftentimes over a one minute period we will have multiple pcaps which cover that period. So what I want to do
Tag: bash
How to run nohup and write its pid file in a single bash statement
I want to run my script in background and then write its pid file. I am using nohup to do this. This is what i came up with, But this gives a syntax error. The following doesn’t give syntax error but the problem is echo $! doesn’t write the correct pid since nohup is run in a sub shell Any
Why does bash behave differently, when it is called as sh?
I have an ubuntu machine with default shell set to bash and both ways to the binary in $PATH: But when I try to call a script that uses the inline file descriptor (that only bash can handle, but not sh) both calls behave differently: The example-script I am referring to looks like that the real one is a little
How to move all files including hidden files into parent directory via *
Its must be a popular question but I could not find an answer. How to move all files via * including hidden files as well to parent directory like this: This will move all files to parent directory like expected but will not move hidden files. How to do that? Answer You can find a comprehensive set of solutions on
gdb backtrace with no user input?
I’m wondering if it’s possible to launch an application via GDB, on a SegFault write the backtrace to a file (to look at later), and then exit GDB all without any user input. I’m running an application from a shell script in an infinite loop (so if it crashes it reloads) on OS boot from a non-interactive session. The application
Script for root to git pull as another user
I have a script that I would like to have do a git pull inside another user’s git directory. This script is run by the root user. For example: When I run this, I get: Is there a way to have my script do a git pull as username? Answer Try without the -i option to sudo. That option is
How to replace string with bash script and write back the Result
There is a CSV file with some columns, the first column is a 5 digit customer number, the other columns are separated with “;” Here is a example: If the first column is empty than I need to set the last given customer ID. The result should look like: Now I read the file linewise with bash script, and want
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 the characters after the first space to have
Number of processors/cores in command line
I am running the following command to get the number of processors/cores in Linux: It works but it does not look elegant. How would you suggest improve it ? Answer nproc is what you are looking for. More here : http://www.cyberciti.biz/faq/linux-get-number-of-cpus-core-command/
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>&1 & to send the command to