Skip to content
Advertisement

Doing an awk command for a conditional statement

I’m doing a bash script using the Awk command to format a file with some user info, and at the beginning of the script, I want it to say “if the value in column 1 is not in the format abc123, skip that line. It doesn’t seem to be working though.

I had this previously:

JavaScript

but of course that wouldn’t work for other input files with different usernames.

So, this is what I’ve tried most recently:

JavaScript

The input file looks like:

JavaScript

Advertisement

Answer

With your shown Input_file the column which we are talking about is $2 NOT $1, so ideally it should be:

JavaScript

Also in case you want to check small and capital both letters then try:

JavaScript
Advertisement