Linux Notes

apt - Advanced Package Tool

Useful commands for writing shell script

set -e, -u, -o, -x pipefail

`set -e` The set -e option instructs bash to immediately exit if any command [1]
has a non-zero exit status. You wouldn't want to set this for your command-line shell,
but in a script it's massively helpful.

Useful variables

  • $@ in Bourne-like shells, in list contexts expands to all the positional parameters as separate arguments. ```shell $> vi script.sh

    script.sh

    #! /bin/sh - exec “$@”

$> script.sh ‘echo’ ‘a b’ ‘x y’

It will call exec with echo, a b, and x y as arguments which will execute echo

(in most sh implementations, /bin/echo as opposed to the echo shell builtin) in the

same process that was previously running the shell interpreting your script with some test and x y as arguments.

```text
command 2> error.log: This redirects StdErr (standard error) of the command to the file error.log. The standard output (StdOut) remains unchanged and continues to be displayed on the terminal.

command 1> out.log: This redirects StdOut (standard output) of the command to the file out.log. The standard error (StdErr) remains unchanged and continues to be displayed on the terminal.

command > error.log: This redirects StdOut (standard output) of the command to the file error.log. However, the standard error (StdErr) is not redirected and continues to be displayed on the terminal.

This is a sapling 🌱 in my digital garden 🏡.

Notes mentioning this note

There are no notes linking to this note.


Here are all the notes in this garden, along with their links, visualized as a graph.

Finance/Banking IdeasOrendaa wishlistTechnical Library IdeasAdaptor PatternDesign PatternsSoftware Design PrinciplesCaaS (Containers As A Service)DevOps NotesDocker Container RegistryDockerFaaS (Functions As A Service) - Serverless...IaaS (Infrastructure As A Service)KubernetesTerraformUsefulunixcommandsConcurrency vs ParallelismDistributed Service with GoDistributed System Learning NotesetcdMetrics, tracing, and loggingProtobufGoLang NotesGoLang ResourcesLearning from JPMakefileLinux NotesAanand Prasad - Creator of Fig/Docker composeMetaprogramming RubyRackDatabase SecuritySecuritySQL InjectionMVPMarket/Startup AnalysisBlue OceanHow to talk to your potential customers?How to work togetherBest way to Launch your startup (Again and Again)Business Process ModelJavascript NotesJavascript ToolsReactJSTypeScript NotesWeb APIs (Browser)Bon appétit!A note about catsTigersBackend DevelopmentBlog WishlistNotable websitesCI/CDHusky - Git commit hookConsistency is keyRedis NotesPostgresql NotesFunny / AmusingGit CLIGraphQL NotesJavascriptJSON Web Token (JWT)Move your body every dayUseful ToolsNot BehindLeslie LamportOpen AIPrivate-Public Key AuthProgramming LanguagesProject EulerRails credentialsRails Devise IntegrationRails Docker Issues and FixesRails-DockerRails NotesReproducible BuildsSemantic VersioningSoftware EngineeringSuccessChandan's TODOCraftman/EngineerYour first seed