Hot answers tagged

4

The problem has nothing to do with nc or netcat or any of their ilk. You are running two commands here, nc and grep, but only redirecting the output of grep. What you want to do is: nc -zv 1.2.3.4 55 &>/dev/null That, of course, would be pointless since if there's no output, you can't grep. That's what grep's -q flag is for: -q, --quiet, --...


2

Here's one way: #!/bin/bash mydate=$(date '+%Y-%m-%d %H:%M:%S') myip=$(curl http://checkip.amazonaws.com?newline -s) printf '%s %s\n' "$mydate" "$myip" >> /home/test_a5gh/Pub_IP.txt FYI, you don't need sudo to chmod files you own in your own home directory.


2

If you want to append successive outputs of a command substitution to an array in bash, you can use a syntax like arr+=( "$(command args)" ) For example, give files with $ grep -H 'versionName' thing* thing1:versionName: foo thing2:versionName: bar thing3:versionName: baz thing4:versionName: boo then $ for f in thing*; do version+=( "$(grep '...


1

According to https://www.dropbox.com/en/help/246, I suggest adding Dropbox's APT repository to your /etc/apt/sources.list by running: sudo add-apt-repository "deb http://linux.dropbox.com/ubuntu xenial main" Then, import Dropbox's GPG keys using: sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E


1

I'm using another solution: echo '$var = <string> 1.11 </string>' | awk -F'> | <' '{print $1,$3}' What I did was defining > and < as delimiters and printing certain fields between the delimiters.


1

As the STDOUT stream is block buffered by default (when not going to terminal) by python, you need to make the stream unbuffered (or line buffered). python provides a way to make the streams unbuffered, here is the Pythonic way: python -u foo.py So, your whole command line becomes: python -u foo.py | ~/timestamp.sh >> ~/logs/foo.log From man ...


1

The root cause is your process, here python, is using libc stdout where the output is line buffered when output to a terminal but block buffered when output to something else, like a pipe here. You can fix the issue either in the python code by explicitly flushing the buffer after each log output: sys.stdout.flush() or by controlling how buffering will ...


1

Run the following: mv /home/folder1/test123 /home/folder1/test456



Only top voted, non community-wiki answers of a minimum length are eligible