How can I close a netcat connection after a certain character is returned in the response?

Create a bash script called client.sh: #!/bin/bash cat someFile while read FOO; do echo $FOO >&3 if [[ $FOO =~ `printf “.*\x00\x1c.*”` ]]; then break fi done Then invoke netcat from your main script like so: 3>&1 nc -c ./client.sh somehost 1234 (You’ll need bash version 3 for the regexp matching). This assumes that the … Read more

how to specify error log file and output file in qsub

Typically error and output files are given as pbs directives in the qsub script or as command line options to the qsub script like so: #! /bin/bash #PBS -q queue_name #PBS -A account_name #PBS -l nodes=12:ppn=12 #PBS -l walltime=18:00:00 #PBS -e /mypath/error.txt #PBS -o /mypath/output.txt or as a command line option to qsub like so: … Read more

Change variables in bash

The (main) problem with your script is that setting min and max happens in a subshell, not your main shell. So the changes aren’t visible after the pipeline is done. Another one is that you’re calling read twice – this might be intended if you want to skip every other line, but that’s a bit … Read more