This was originally posted on my blog a while ago
I was given a fairly mundane task at work and when this happens I try and find ways to make it i...
For further actions, you may consider blocking this person and/or reporting abuse
Cool command! You could remove the head bit though with awk.
By default the condition is NUL, which matches every line (so the command is run on every line). You have access to different variable (in both the condition and the command I think), one of them being
NR
for the line number.So, if you set the condition to
NR!=1
, it'll run on every line different than 1 (which is the first one).So, your command can be shortened from:
to
:smile:
I learned a bunch otherwise, so thanks!
Thanks for the improvements!
data.csv
column -s, -t < data.csv
Not applicable to general CSV.
I've never used
column
before. That's pretty cool.As far as the WTFness of it all goes, if you split it up and assign variables with nice names it'll be easy enough to understand. There's something about shell scripts though that make people write things as tersely as possible. I'd end up with something like that and refer back to it in my history if I needed it again soon after, but if I made it into a script I'd either comment the hell out of it or split it into parts, I think.
Bugfix:
if it did that, it'd be
head
:) The plus means take the offset from the start of the file instead of the end.May I suggest csvkit as a means to work with CSV data at the command line? It has several nifty tools to handle CSV files including getting rid of the column headers, splitting and merging several tables by columns, and even has ways of converting Excel xlsx tables to csv. I would recommend giving it a try if you have to deal with these types of files at the command line.