User Tools

Site Tools


resources:awk_resources

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
resources:awk_resources [2016/01/14 12:55] – created anthonyresources:awk_resources [2019/05/22 16:08] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +~~TOC:1-4~~
 +
 ====== awk programming resources ====== ====== awk programming resources ======
  
Line 5: Line 7:
 <2016-01-14> <2016-01-14>
  
-Anthony did this for the MathWONC project (see [[internal:mathwonc2015_notes|here]]).+Anthony did this for the MathWONC project (see [[internal:mathwonc2015_notes#awk_script_for_cleaning_up_spm_tables|here]]).
  
 Here is the code from ''cleanup_awk_linux.sh'': Here is the code from ''cleanup_awk_linux.sh'':
Line 32: Line 34:
 rm temp.csv rm temp.csv
 </code> </code>
 +
 +\\
 +----
 +
 +
 +====== Sort article lists by year using awk and sed ======
 +
 +[Originally from Anthony's ''science.txt'' file, entry dated 2015-07-18.]
 +
 +Exported bibliography to clipboard in Zotero, pasted into Emacs to write new file: 
 +
 +''.../VNLab/studies/ipsNumMeta/sources_number.txt''
 +
 +
 +Try using awk to print column with year before whole rest of line
 +
 +<code bash>
 +gawk '{match($0,"\\([0-9]*[a-z]?\\)",a)} {print a[0], $0}' sources_number.txt > sources_number_yearCol.txt
 +</code>
 +
 +Remove parens from FIRST (year) on a line:
 +
 +<code bash>
 +sed -r 's/[(]([0-9]*[a-z]?)[)]/\1/' sources_number_yearCol.txt > sources_number_yearCol_noParens.txt
 +</code>
 +
 +Used rectangle register copy trick in Emacs to copy only first five chars (catches both 2012 and 2012b) and pasted ultimately to Excel column.
  
 \\ \\
resources/awk_resources.1452794130.txt.gz · Last modified: 2019/05/22 16:08 (external edit)