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

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 '...


2

Click in Ubuntu icon (the first bottom in side menu). Write gedit Open Text Editor clicking in its icon. Click in Open. In the list, write: ~/.bashrc Enter Clean your failing .bashrc file. Save and you can open terminal again.


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.


1

Not really one single command, but why make it more complicated than necessary? find -type f -name ".*" -delete; rm *~ The first command removes all files starting with . and the second one all ending with ~


1

Bash makes a difference between single quotes '...' and double quotes "...". Single quotes cause the enclosed text to be taken literally while double quotes allow various interpretations of the string like variable expansion. You must use double quotes if you have $x-like Bash variables in your string which you want to be expanded. Additionally, directly ...


1

You asked "How do I concatenate them?" - and the answer is, quite simply, with cat: NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION]... [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. Note in particular that its inputs can include standard input, not just files. ...


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


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

edit your ~/.zshrc source /etc/zsh_command_not_found and run source ~/.zshrc



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