5 added 52 characters in body
source | link

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in the tab delimited-delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

UPDATE - based on the suggestion from @glennjackman after adding -v for each variable @glennjackman, there is a different error message.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' -v var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message:

awk: can't open file MAP_pv1.txt_cap.txt
 source line number 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

UPDATE - based on the suggestion adding -v for each variable @glennjackman

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' -v var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message:

awk: can't open file MAP_pv1.txt_cap.txt
 source line number 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in the tab-delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

UPDATE - based on the suggestion from @glennjackman after adding -v for each variable, there is a different error message.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' -v var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message:

awk: can't open file MAP_pv1.txt_cap.txt
 source line number 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

4 added 443 characters in body
source | link

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

UPDATE - based on the suggestion adding -v for each variable @glennjackman

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' -v var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message:

awk: can't open file MAP_pv1.txt_cap.txt
 source line number 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

UPDATE - based on the suggestion adding -v for each variable @glennjackman

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' -v var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message:

awk: can't open file MAP_pv1.txt_cap.txt
 source line number 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

3 deleted 4 characters in body
source | link

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, "$2$2, "$5$5, "$6$6, "$7$7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, "$2, "$5, "$6, "$7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

I am trying to print out columns that are separated by tabs.

First, I use find command to identify a list of files to process.

Second, I parse the file path to generate the filename to be used for output later using split.

Third, I print out a few columns that I needed (including the first column is combined from a few columns with underscore) in tab delimited format specified using -v OFS='\t'.

Forth, I print out the output path and the file name ended with _step3.

INPUT="/Users/dir/in"
OUTPUT="/Users/dir/out/"
find "$INPUT" -type f -iname "*.txt_cap.txt" -execdir awk -v OFS='\t' var="$OUTPUT" '{n = split(FILENAME,p,"/"); print ($1"_"$2"_"$4"_"$3, $2, $5, $6, $7) >> (var p[n] "_step3")}' {} +

I got the following error message. What went wrong?

awk: syntax error at source line 1
 context is
     >>>  <<< 
awk: bailing out at source line 1

A side question, when I use find "$INPUT" -type f -iname "*.txt_cap.txt" I could see a list of files shown on the terminal. I was also able to see the files displayed when using "$INPUT" -type f -iname "*.txt_cap.txt". But when combined with awk, the first one with longer file matching pattern, I was able to get error messages for the command, but there was no error messages and no output files generated when just .txt used as matching pattern. Does anyone know the reason for the silence behavior?

Thank you.

2 added 170 characters in body
source | link
1
source | link