Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

To delete the "last" (highest-numbered "run") log file for each set of jobs and dates, I would suggest a ksh93-based solution that can keep track of the highest job runs seen for each combination as well as a list of files to delete: #!/bin/ksh93 typeset -A highestjobruns=() typeset -A deletions=() for logfile in *_????????_*.log do base=${logfile%.log} ...


0

As far as I know those are not logged. Unless somebody else proves me wrong, here's an alternate method. What you can do instead is steps 1+2 or 1+3 below: disable rp_filter completely. use iptables' rpfilter match module, once with the LOG target for simple log, or NFLOG (or even NFQUEUE though that's not the intended usage) for full packet dump, and once ...


0

I just want to say it happens only on kernels 4.9.x [and above] on whatever distro. O.K. so the kernel bisection says the guilty commit is: https://github.com/torvalds/linux/commit/b5c0875a16039d90f4cdf6b75ae4031daae01d56 commit b5c0875a16039d90f4cdf6b75ae4031daae01d56 Author: Lv Zheng <lv.zheng@intel.com> Date: Thu Aug 4 16:...


0

For simple filenames such as these, where you can guarantee that they will not contain strange characters such as newline, it is safe and convenient to parse the output of ls. (In the general case this is not recommended.) As described in your question let's assume we're working with files matching these pattern, where the * will of course match "anything": ...


1

Using grep: $ grep -o '\(src\|dst\)=[^:]\+:[^:]\+\|proto=[^ ]\+' logfile.txt src=12.1.1.11:49894 dst=4.2.2.2:53 proto=udp/dns Description: '\(src\|dst\)= match src or dst followed by = [^:]\+:[^:]\+ one or more non-colon characters, followed by :, followed by one or more non-colon characters \| or proto=[^ ]\+' match proto= followed by one or more non-...


1

Based on what you have: awk '{print $18,$19,$21}' OFS=" , " logfile.txt | sed 's|:X[0-1]||g' You don't need cat as awk already writes to stdout. The command above prints those fields separated by a space which is what the comma does and then it sets the field separator as a comma surrounded by spaces and uses sed to remove :X0 and :X1. The output: src=12....


0

Another alternative to retrieve the system boot date consist using vmstat(8) in statistics mode with --stats argument. The command expose the following line: ... TIMESTAMP boot time ... So the line can be parsed with gawk(1) and the timestamp can be converted using the date(1) command to a human readable format with the command below: $ TIMESTAMP=$(...


0

Add this code to /etc/profile mkdir /var/log/history;chmod 777 /var/log/history USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` export HISTFILE=/var/log/history/$(whoami)-$USER_IP-history You olso can add history filename to using date.


0

The env vars are environment variables. These are a list of variables that executed applications have access to. An application may be executed with different env vars values, and this may change its behaviour. In a shell script, these are easily accessible. Eg. in Bash an env var is called the same as any other variable - simply by its name. In this ...


0

It should work with double quotes like smbclient //10.10.101.29/it -W WORKGROUP -U user --password pass -c "put file_$(date +%Y_%m_%d).file" or date=$(date +%Y_%m_%d) smbclient //10.10.101.29/it -W WORKGROUP -U user --password pass -c "put file_${date}.file"


2

Assuming it's the log rotation facility that renames the file to include the date in the filename, one way this could happen if no data whatsoever was actually written to the file between the 10th and when it was rotated, on the 12th. The 12th of May 2019 was a Sunday, and weekly logfile rotations would typically happen on Sundays. The 10th of May 2019 was ...


4

Because you used double quotes, $? is getting expanded when you assign the value - as you can verify using set -x: $ PROMPT_COMMAND="echo $?" + PROMPT_COMMAND='echo 0' ++ echo 0 0 If you change the double quotes to single quotes, you should get the desired behaviour: $ PROMPT_COMMAND='echo $?' + PROMPT_COMMAND='echo $?' ++ echo 0 0 i.e. $ set +x + set +...


0

Just put it in a var after the command. /home/exit_status$ export PROMPT_COMMAND="echo $?" 0 /home/exit_status$ rm / rm: cannot remove ‘/’: Is a directory 0 ...


Top 50 recent answers are included