awk select second field stored in a variable 1

awk select second field stored in a variable

y=$(echo $x | awk '{print $2}')
echo $y

Here is what the above code is Doing:
1. It’s taking the output of the command “ls -l” and piping it to the awk command.
2. The awk command is taking the output of the ls -l command and printing the second column.
3. The output of the awk command is then stored in the variable y.
4. The variable y is then printed.

Similar Posts