I am brand new to shell scripting and cannot seem to figure out this seemingly simple task. I have a text file (ciphers.txt) with about 250 lines, and I would like to use the first column of each line as an argument in a command. Any help would be greatly appreciated!
the command is:
openssl s_client -connect host:port -cipher argument
It works fine when I do one at a time but I do not really want to run the same command 250+ times. Here is my script so far:
awk '{command = "openssl s_client -connect localhost:4433 -cipher > results.txt" print $0 | command}' ciphers.txt
I keep getting an error so I am pretty sure I have a syntax error somewhere. Is the output of awk being appended after -cipher?
Call External Command From awkawk + cp: Read input of a file list, and copy the files to a required destination with a defined name pattern. awk + md5sum: Read input containing a list of filenames, output the filename and the MD5 hash of the file.
awk '{print $1}' information. txt prints the first column. Then the output of that command (which you saw earlier on) is piped, using the pipe symbol | , to the head command, where its -1 argument selects the first line of the column.
In order to tell awk to use that file for its program, you type: awk -f source-file input-file1 input-file2 … The -f instructs the awk utility to get the awk program from the file source-file (see Command-Line Options). Any filename can be used for source-file .
`awk` command uses '-v' option to define the variable. In this example, the myvar variable is defined in the `awk` command to store the value, “AWK variable” that is printed later. Run the following command from the terminal to check the output.
Use system
from within awk:
awk '{ system("openssl s_client -connect host:port -cipher " $1) }' ciphers.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With