This material of this faq originates from the comp.lang.awk FAQ that you can find there: * http://www.faqs.org/faqs/computer-lang/awk/faq/ <toc> ---- == What is Awk? <include "What is awk"> [[http://awk.freeshell.org/?action=edit;id=What_is_awk| Edit this answer]] ---- == How can I access shell or environment variables in an awk script? === Shells <include "Shells"> [[http://awk.freeshell.org/?action=edit;id=Shells| Edit this answer]] === Environment variables in general <include "EnvVarGeneral"> [[http://awk.freeshell.org/?action=edit;id=EnvVarGeneral| Edit this answer]] === Unix Shell Quoting <include "ShellQuoting"> [[http://awk.freeshell.org/?action=edit;id=ShellQuoting| Edit this answer]] === ENVIRON[] and "env"|getline <include "ENVIRON"> [[http://awk.freeshell.org/?action=edit;id=ENVIRON| Edit this answer]] === exporting environment variables back to the parent process <include "PassingVariablesToTheParentProcess"> [[http://awk.freeshell.org/?action=edit;id=PassingVariablesToTheParentProcess| Edit this answer]] ---- == Why would anyone still use awk instead of perl? <include "AwkVsPerl"> [[http://awk.freeshell.org/?action=edit;id=AwkVsPerl| Edit this answer]] ---- == How do I report a bug in gawk? <include "How do I report a bug in gawk"> [[http://awk.freeshell.org/?action=edit;id=How_do_I_report_a_bug_in_gawk| Edit this answer]] ---- == Is there an easy way to determine if you have oawk or nawk? <include "oawk or nawk"> [[http://awk.freeshell.org/?action=edit;id=oawk_or_nawk| Edit this answer]] ---- == How does awk deal with multiple files? === Version warning Some of these techniques will require non-ancient versions of awk. === How can awk test for the existence of a file? <include "FileExistence"> [[http://awk.freeshell.org/?action=edit;id=FileExistence| Edit this answer]] === How can I get awk to read multiple files? <include "ReadMultipleFiles"> [[http://awk.freeshell.org/?action=edit;id=ReadMultipleFiles| Edit this answer]] === How can I tell from which file my input is coming? <include "FileName"> [[http://awk.freeshell.org/?action=edit;id=FileName| Edit this answer]] === How can I get awk to open multiple files (selected at runtime)? <include "OpeningFiles"> [[http://awk.freeshell.org/?action=edit;id=OpeningFiles| Edit this answer]] === How can I treat the first file specially? <include "FirstFile"> [[http://awk.freeshell.org/?action=edit;id=FirstFile| Edit this answer]] === How can I explicitly pass in a filename to treat specially? <include "SpecialFile"> [[http://awk.freeshell.org/?action=edit;id=SpecialFile| Edit this answer]] ---- == How many elements were created by split()? <include "SizeOfSplit"> [[http://awk.freeshell.org/?action=edit;id=SizeOfSplit| Edit this answer]] ---- == How can I split a string into characters? <include "SplitIntoChars"> [[http://awk.freeshell.org/?action=edit;id=SplitIntoChars| Edit this answer]] ---- == Why does SunOS/Solaris awk behave oddly? <include "SolarisNawk"> [[http://awk.freeshell.org/?action=edit;id=SolarisNawk| Edit this answer]] ---- == How do I have dynamic-width printf strings, like C? <include "PrintfDynamicWidth"> [[http://awk.freeshell.org/?action=edit;id=PrintfDynamicWidth| Edit this answer]] ---- == Why doesn't "\\$" behave like /\\$/ ? Why don't parentheses match? <include "BackslashInRegexp"> [[http://awk.freeshell.org/?action=edit;id=BackslashInRegexp| Edit this answer]] ---- == What is awk's exit code? <include "ExitCode"> [[http://awk.freeshell.org/?action=edit;id=ExitCode| Edit this answer]] ---- == How can I get awk to be case-insensitive? <include "CaseInsensitive"> [[http://awk.freeshell.org/?action=edit;id=CaseInsensitive| Edit this answer]] ---- == How can I force a numeric/non-numeric comparison? <include "ForceNumeric"> [[http://awk.freeshell.org/?action=edit;id=ForceNumeric| Edit this answer]] ---- == Why does { FS=":"; print $1 } not split the first record? <include "WhenAreTheFieldsSet"> [[http://awk.freeshell.org/?action=edit;id=WhenAreTheFieldsSet| Edit this answer]] ---- == Why does awk 'BEGIN { print 6 " " -22 }' lose the space? <include "ConcatenationPrecedence"> [[http://awk.freeshell.org/?action=edit;id=ConcatenationPrecedence| Edit this answer]] ---- == Credits original faq: http://www.faqs.org/faqs/computer-lang/awk/faq/ These people have contributed to the well-being of the FAQ: {{{ arnold [at] skeeve.com (Arnold D. Robbins) walkerj [at] compuserve.com (James G. Walker) jland [at] worldnet.att.net (Jim Land) yuli.barcohen [at] telrad.co.il (Yuli Barcohen) johnd [at] mozart.inet.co.th (John DeHaven) amnonc [at] mercury.co.il (Amnon Cohen) saguyami [at] post.tau.ac.il (Shay) hankedr [at] mail.auburn.edu (Darrel Hankerson) mark [at] ispc001.demon.co.uk (Mark Katz) brennan [at] whidbey.com (Michael D. Brennan) neitzel [at] gaertner.de (Martin Neitzel) pjf [at] osiris.cs.uoguelph.ca (Peter Jaspers-Fayer) dmckeon [at] swcp.com (Denis McKeon) neil_mahoney [at] il.us.swissbank.com (Neil Mahoney) dzubera [at] CS.ColoState.EDU (Zube) allen [at] gateway.grumman.com (John L. Allen) jerabek [at] rm6208.gud.siemens.co.at (Martin Jerabek) thull [at] ocston.org (Tom Hull) bmarcum [at] iglou.com (Bill Marcum) thobe [at] lafn.org (Glenn Thobe) boffi [at] rachele.stru.polimi.it (giacomo boffi) hastinga [at] tarim.dialogic.com (Austin Hastings) konrad [at] netcom.com (Konrad Hambrick) jmccann [at] WOLFENET.com (James McCann) eia018 [at] comp.lancs.ac.uk (Dr Andrew Wilson) Alex.Schoenmakers [at] lhs.be rwab1 [at] cl.cam.ac.uk (Ralph Becket) jesusmc [at] scripps.edu (Jesus M. Castagnetto) monty [at] primenet.com (Jim Monty) epement [at] ripco.com (Eric Pement) gavin [at] wraith.u-net.com (Gavin Wraith) pierre [at] mail.asianet.it (Gianni Rondinini) lothar [at] u-aizu.ac.jp (Lothar M. Schmitt) morrisl [at] scn.org (Larry D. Morris) Juergen.Kahrs [at] t-online.de kahrs [at] iSenseIt.de (Juergen Kahrs) tim [at] consultix-inc.com (Tim Maher/CONSULTIX) phil [at] bolthole.com (Philip Brown) andrew_sumner [at] bigfoot.com (Andrew Sumner) jblaine [at] shore.net (Jeff Blaine) dmeier.esperanto [at] gmx.de (Detlef Meier) heiner.steven [at] nexgo.de (Heiner Steven) joe [at] plaguesplace.dyndns.org hstein [at] airmail.net (Harry Stein) ptjm [at] interlog.com (Patrick TJ McPhee) db21 [at] ih4ess.ih.lucent.com (David Beyerl) art [at] pove.com (Art Povelones) jari.aalto [at] ntc.nokia.com (Jari Aalto) jlaiho [at] ichaos.nullnet.fi (Juha Laiho) walter [at] wbriscoe.demon.co.uk (Walter Briscoe) SimonN [at] draeger.com (Nicole Simon) peter.tillier [at] btinternet.com (Peter S Tillier) churchyh [at] ccwf.cc.utexas.edu (Henry Churchyard) Ferran.Jorba [at] uab.es (Ferran Jorba) Kalle.Tuulos [at] nmp.nokia.com (Kalle Tuulos) rms [at] friko.onet.pl (Rafal Sulejman) pjfarley [at] banet.net (Peter J. Farley III) neel [at] gnu.org afu [at] wta.att.ne.jp pez68 [at] netscape.net (Peter Stromberg) edgar.j.ramirez [at] lmco.com (Edgar J. Ramirez) pholzleitner [at] unido.org (Peter HOLZLEITNER) bps03z [at] email.mot.com (Peter Saffrey) jidanni [at] kimo.com.tw (Dan Jacobson) lehalle [at] earthling.net (Charles-Albert Lehalle) robin.moffatt [at] ntlworld.com (Robin Moffatt) markus [at] biewer.com (Markus B. Biewer) vincent [at] delau.nl (Vincent de Lau) vjpnreddy [at] hotmail.com (Jaya Reddy) David.Billinghurst [at] riotinto.com (David Billinghurst) j-korsv [at] online.no (Jon-Egil Korsvold) }}}
Summary:
This change is a minor edit.
Username: