Skip to main content

Three Tips for the Linux Shell Addict

This time around we have three great tips for the Linux shell addict, three sites that will increase your productivity and save valuable time in your daily interactions with the shell.

The first one is ok-b.org. It's a shell snippet search engine where you get to  describe the task you are after in natural English and in return be presented with closely related snippets.

For example, in looking up "How to list only files?", will bring up:
Bash: How to list only files?
  • find . -maxdepth 1 -type f
  • ls -l | egrep -v '^d'
  • ls -l | grep -v '^d'

List only common parent directories for files
read -r FIRSTLINE
DIR=$(dirname "$FIRSTLINE")
while read -r NEXTLINE; do
  until [[ "${NEXTLINE:0:${#DIR}}" = "$DIR" || "$DIR" = "/" ]]; do
    DIR=$(dirname "$DIR")
  done
done
echo $DIR

How to list files in directory using bash?
for file in /source/directory/*
do
    if [[ -f $file ]]; then
        #copy stuff ....
    fi
done


Comments

Popular posts from this blog

RAG from Scratch

  The "RAG from Scratch" tutorial by Langchain coupled with the "RAG playground" are two great educational resources that will help you kickstart your journey with RAG. https://www.i-programmer.info/news/105-artificial-intelligence/17676-rag-from-scratch.html

Hour Of Code 2024 Is About To Kick Off

  This year the event that aims to provide a coding experience for all school students and anyone else who wants to join in runs between December 9th and 15th and includes new activities. Let's find out all about it! https://www.i-programmer.info/news/150-training-a-education/17664-hour-of-code-2024-is-about-to-kick-off.html