Skip to main content
27 events
when toggle format what by license comment
Mar 30, 2021 at 9:58 vote accept pleasehelp
Mar 28, 2021 at 16:38 comment added Ed Morton If any of the answers solves your problem then see unix.stackexchange.com/help/someone-answers for what to do next, otherwise provide feedback and/or questions about any issues.
Mar 28, 2021 at 13:46 history edited pleasehelp CC BY-SA 4.0
deleted 300 characters in body
Mar 27, 2021 at 20:00 history became hot network question
Mar 27, 2021 at 19:40 comment added G-Man Says 'Reinstate Monica' (Cont’d) …  Please edit your question again to show exactly what you are running and what you are getting.  If you are really getting output similar to what you show, please run awk -V (or awk --version) and tell us what that says.  (It's conceivable that you might get unexpected, non-conformant results from awk if you are running a sufficiently old, brain-damaged version of it.)
Mar 27, 2021 at 19:40 comment added G-Man Says 'Reinstate Monica' (1) You listed t and s in the wrong order. That doesn't matter, but the fact that you listed E as a consonant is an error.  (2) I agree with @EdMorton on two levels.  (2a) It is totally impossible for the command that you show to produce the output you show. For it to have any chance of working, the file names would have to be on the same command line as the awk command.  (2b) Even if you fix that error, it should not be producing the 0. … (Cont’d)
S Mar 27, 2021 at 18:38 history edited G-Man Says 'Reinstate Monica' CC BY-SA 4.0
formatting and typos
S Mar 27, 2021 at 18:38 history suggested mik CC BY-SA 4.0
formatting and typos
Mar 27, 2021 at 17:24 review Suggested edits
S Mar 27, 2021 at 18:38
Mar 27, 2021 at 16:58 comment added Ed Morton If you fix that though to have the file names listed as arguments as shown in my answer then it's impossible for that script to print a 0 because the only print statement is printing 2 values at a time, a file name and a count, and even if the file name was somehow null (which it isn't), there would still be a space before the count. I'm sorry but what you say is happening 100% cannot happen as a result of running my script. You must have something else you're doing to print that first 0.
Mar 27, 2021 at 16:46 comment added Ed Morton The command you showed under "for the following code (provided by Ed Morton):" would take the strings file1 and file2` as input to the script, not as the names of file names containing input to the script, it cannot produce the output you say it does. Please edit your question to show exactly the command you ran so we can help you.
Mar 27, 2021 at 15:59 history edited pleasehelp CC BY-SA 4.0
added 308 characters in body
Mar 27, 2021 at 13:41 answer added ilkkachu timeline score: 2
Mar 27, 2021 at 13:33 history edited ilkkachu CC BY-SA 4.0
added 1 character in body
Mar 27, 2021 at 13:30 history edited pleasehelp CC BY-SA 4.0
added 64 characters in body
Mar 27, 2021 at 13:17 history edited pleasehelp CC BY-SA 4.0
added 3 characters in body
Mar 27, 2021 at 13:14 answer added Ed Morton timeline score: 6
Mar 27, 2021 at 13:14 history edited pleasehelp CC BY-SA 4.0
added 151 characters in body
Mar 27, 2021 at 13:11 history edited Ed Morton CC BY-SA 4.0
edited body
Mar 27, 2021 at 13:06 history edited Ed Morton CC BY-SA 4.0
deleted 25 characters in body
Mar 27, 2021 at 12:58 comment added pleasehelp @steeldriver so where exactly should I put the BEGINFILE ?because everything I tried didn't work
Mar 27, 2021 at 12:46 comment added steeldriver @pleasehelp the BEGINFILE rule only needs to reset the counter. The actual matching/counting needs to remain in a separate rule that is applied to all records, like you originally had it.
Mar 27, 2021 at 12:33 comment added pleasehelp @steeldriver I tried gawk -v FS="" 'BEGINFILE{for ( i=1;i<=NF;i++){if($i ~/[bcdfghjklmnpqrtsvwxyzBCDEFGHJKLMNPQRTSVWXYZ]/) count_c++}} ENDFILE {print FILENAME,count_c}' file1 file2 but it isn't doing anything
Mar 27, 2021 at 12:18 history edited pleasehelp CC BY-SA 4.0
deleted 6 characters in body
Mar 27, 2021 at 12:12 comment added pleasehelp @steeldriver no I don't have it:(((,could it somehow be done with awk?
Mar 27, 2021 at 12:04 comment added steeldriver Do you have GNU awk (gawk)? if so, you can use ENDFILE in place of END (and add a BEGINFILE rule to reset the counter)
Mar 27, 2021 at 12:00 history asked pleasehelp CC BY-SA 4.0