💾 Archived View for zigford.org › speed-up-your-shell-game.gmi captured on 2023-11-04 at 11:31:50. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-03-20)

-=-=-=-=-=-=-

about

links

scripts

Sharing linux/windows scripts and tips

Speed up your shell game

April 21, 2019 — Jesse Harris

Part of good use of the shell is doing repetitive things fast. A GUI can often be faster than using the command line because you can almost select things with your eyes ( eg, shift click files in a list to copy selectively. ) You can't always use a gui, however.

~~~

Perhaps your forced to move files around through the terminal. Today I was faced with such a task and to make matters worse, the files were quite large. So copying them individually would take a long time, and running them in parallel by using the & trick would have lead to huge io issues.

By defining a few quick and dirty functions, I was able to make my job a lot easier:

```

function add() { echo "${1}" >> ~/list.txt; }

```

```

function l() { ls | grep -i "^$1.*"; }

```

```

function upload() {

cat ~/list.txt | while read p

do

[[ -f "${p}" ]] &&

[[ ! -f /media/extHDD/"${p}" ]] &&

echo "Copying : ${p}" &&

cp "${p}" /media/extHDD/

done

}

```

Using these functions together, I would use l a to list all the files starting with a, then add a_file_.mkv to add it to the list to be processed.

Finally, use upload to have files pushed to the destination.

As you can see, none of these function are special or tricky, just simple little hacks to reduce keystrokes and make a job easier. I would say the main learning is, whatever you are doing use the tools to make your life easier.

Tags:

bash

shells

© Jesse Harris

mailto:jesse@zigford.org

Generated with bashblog, a single bash script to easily create blogs like this one

bashblog