User Tools

Site Tools


resources:awk_resources

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
resources:awk_resources [2016/01/14 12:57] anthonyresources:awk_resources [2019/05/22 16:08] (current) – external edit 127.0.0.1
Line 34: 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.1452794225.txt.gz · Last modified: (external edit)