Skip to content

Instantly share code, notes, and snippets.

@walterhiggins
walterhiggins / sample.json
Last active August 4, 2023 10:39
sample json
{
title: "This is the title",
person: {
name: "Walter",
gender: "Male"
}
items: [
{id: 5, name: "Jupiter"},
{id: 7, name: "Saturn"},
{id: 9, name: "Mars"}

I've been using xargs for years without truly understanding what it did. I assumed it repeated the same command on each file but instead it runs the command passing all the files as arguments.

To run a command on multiple files - 1 file at a time - do this:

for file in $DIRECTORY/*; do ${YOUR_COMMAND_HERE} ${file}; done

For example: to revert local changes in a git-managed directory:

(function(exports) {
var bands = [
{
name: "The Beatles",
members: [
{
name: "George Harrison",
instrument: "Lead Guitar",
bio: "Blah blah blah",
songs: ["While my guitar gently weeps", "Here comes the sun"]
  1. Sean Higgins
  2. Adam Ahern
  3. Brendan Sheehan
  4. Caleb Bourke
  5. Rian McCormack
  6. Jack Murphy
  7. Cian Murphy
  8. Ian Elliot
  9. Sam Metcalfe
  10. Conor Lee
  1. Warmup
    • Jumping Jacks x 10
    • Seals x 10 (clap in front)
    • High Knees
    • Lunges
    • Side-shuffle
    • Soldier Kicks
    • Sprints
  2. Clear the goal game https://www.youtube.com/watch?v=-FHm-rz0dr0 2 teams, aim is for each team to score as many goals as possible in 2 minutes.