Search Results

Search: Posts Made By: CarlosNC
6,063
Posted By CarlosNC
If there are spaces instead of commas, just...
If there are spaces instead of commas, just remove the -F, from the statement, and replace "," with " " in the third line.

awk '
NF == 2 {x=$1; print; next}
NF == 1 {print x" "$1}
' infile >...
6,063
Posted By CarlosNC
Assuming the number of columns is consistent...
Assuming the number of columns is consistent throughout, and in this case is 1 or 2, an awk script might look like:

awk -F, '
NF == 2 {x=$1; print; next}
NF == 1 {print x","$1}
' infile >...
2,012
Posted By CarlosNC
Thanks Jim, that makes sense using grep, but I...
Thanks Jim, that makes sense using grep, but I should have been more clear, it needs to be awk because there is more to my script, but I removed it to simplify my post here. I use awk here because I...
2,012
Posted By CarlosNC
Varying number of awk search strings
I've created an awk script that handles a varying number of search strings handed to it as command line parameters ($1 $2 etc). There may be 1, or 2 or 3 or more. A simplified version of the script...
9,597
Posted By CarlosNC
Thanks Jim, Your first option worked fine, and...
Thanks Jim,
Your first option worked fine, and made it easier for me to convert the info into an array in awk (with the split function) which was my goal.
9,597
Posted By CarlosNC
getopts with repeat of same option
Hello,
Does getopts have some way of handling the use of an option that requires a parameter more than once on the command line.
e.g. mycmd -a john -a jane
I came up with a solution using...
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 10:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy