From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E49B21580E0 for ; Tue, 10 Jun 2025 14:34:27 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id C87CA34326D for ; Tue, 10 Jun 2025 14:34:27 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id B4FA81104B8; Tue, 10 Jun 2025 14:33:21 +0000 (UTC) Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 6B8D81103DA for ; Tue, 10 Jun 2025 14:33:20 +0000 (UTC) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-32a6c473e28so4390361fa.0 for ; Tue, 10 Jun 2025 07:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749565998; x=1750170798; darn=lists.gentoo.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=n45bwF6WDPF5SaOa4IEtnHyPDq+kZ9aN48S2nf7nCRc=; b=T3LRImKQrQ4Ofd1MZ0beZiwErpd6Z4gSjSKgaZ9XHK/XFPpMj8ndQskwViha8xxcn6 C90bx1Ot1zESCDgBg8APQ7mpu7j94kr0LYCutKJdRltuDgDDZywDvc07/E04/1sekuuo 0G2E29oD9DPp/+a7ikzhKoJwc8HStYZCHMG64OHsODAEgVQ6ycwCebUhrRi6qrkM8Yot 0T+TWg4ULeG6dt/rpUIGrksRSEkbDi/SerBX9Ypypf1xCCSFGfbPDn0gJSn/yr5xXiKk Jskfqkzvqy1puRcwI6PzoqptafF1zbzFSCK3qn07Trcfilzi5pGNP65e+YhZ0nJN8jfP yfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749565998; x=1750170798; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n45bwF6WDPF5SaOa4IEtnHyPDq+kZ9aN48S2nf7nCRc=; b=U/AmfEjyZO8YiZL5jelJkRejc67h4RL5Uu4Q7EMXb122PqR5UVfqHLauvNxbKtU08/ 5MkiE8opDEjSClNAFJ41JIOb6QGNQL4XT3VooaK7rNzFsMOYnMRQ6bIOn5qIZc9eOm5I cF9sJIRhSdt/gGMQZnzn2GYLGYqV9M3OEAqb1Q9B+X3g50Kbq6NPdzWCwkM63UJQVZp+ y/uFYtjI8zpb1RigQMNJFyBAChw9qJBOVpeuHPFpZQaWn9h8YCgtTOAmSkidlA7SYFTJ Kz3mNaVrcwy1y44IhiTIffgUpbV+HxayZ9Mrf0jxhStVeA8qJNuz7NaqamZcbbbucmEV Hzpw== X-Gm-Message-State: AOJu0YxJAbJ7q4wHCs9kovSCHU2kKUhsbMMsFIq+r40O2pAc6OCOTEHQ plBnQb+AYuzXhIWFkIEF1Hfwtn7l+vNZj3wV9pev+9JrAb8AZr9uKgySlGo6WD/copxI/B3ObNh x3w+UpPrPvGlDOFwJgFFREGitHfAWA4aIDdbM X-Gm-Gg: ASbGncvTCmgkYvK5YFGTsgYdU6CxzyGJAoPzk8vOWRMX7f7y+oC+zWnMDDrnV2KboIi pPb3o5Npq6wItqwW758vI6ZfIZoUtsp/miFC8MS1A1v8fR8+cNDnuYrM1MWVTSD52S88nax57jN o7xFvaNgvwqV8v8GFS7Caw6TvIuALLKWVnnM2asShBquk= X-Google-Smtp-Source: AGHT+IGPDKbQjfDJmj4J4Th8Xr4o0N2i3PN0wAMZ3BqYUp8dNkvOAIlD5lc1YV82aK13n24nYnxqAv+FyH2XiPNLGLk= X-Received: by 2002:a05:651c:19ac:b0:32a:714c:12c1 with SMTP id 38308e7fff4ca-32ae323193fmr13118391fa.3.1749565997516; Tue, 10 Jun 2025 07:33:17 -0700 (PDT) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 References: <1a0acd33-22d2-d378-6d8d-87a5302242f8@gmail.com> In-Reply-To: From: Mark Knecht Date: Tue, 10 Jun 2025 07:33:05 -0700 X-Gm-Features: AX0GCFsZXypajCWDshuP9jnxaejiwS2y8tDR5gaU_r8NT7AFEgQish1Zf9CXgTs Message-ID: Subject: Re: [gentoo-user] Books about making shell scripts and other nifty commands. To: gentoo-user@lists.gentoo.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 6af5f65d-fc67-4e54-bfb4-81775a4a5dfa X-Archives-Hash: f30e60e2b7f4e04738bcbb563ae5dd91 On Tue, Jun 10, 2025 at 2:42=E2=80=AFAM Dale wrote: > > Dale wrote: > > Howdy, > > > > <<< SNIP >>> > > So, I'm looking for a book, paperback would be nice but hardback is fin= e > > too. I found this. I may look for a used version elsewhere too. > > Reading what is described, this sounds like a good place to start. > > > > https://www.amazon.com/Super-Easy-Linux-Bash-Scripting/dp/B0F7GF439K > > > > <<< SNIP >>> > > > > Any thoughts on one I linked too? Will that be OK for me to start out > > with given my VERY basic skills? Know of something better? When I was > > a kid, I was pretty good with BASIC on the old Commodore VIC-20 and 64. > > That was a LONG time ago tho. > > > > Thanks. > > > > Dale > > > > :-) :-) > > > > > I got the book in. It's a good book for someone who is new to Linux. > Maybe coming from Windows or something where commands are different. It > talks about a lot about common commands and such and does touch on > scripts a bit. Thing is, it isn't what I'm looking for. I'm looking > for how scripts work and how and why they are formatted and such. I > have questions like what does the "{" and "}" do? How do I get it to > check something and if one result matches it does A but if it is some > other result it does B? Example. > > I'm wanting to write a script that opens a encrypted drive and mounts > the drive. When I run the script, I first want it to check and see if > it is still locked or not. If it is still locked, ask for the > passphrase and unlock. If it is unlocked, then move to the next part > for mounting. If it is already mounted, then nothing is needed. If it > is not, mount the drive. I'd also like it to print out what it is doing > or not doing as well. Back in the old basic days, we had "goto" and > such. I don't see that in bash type scripts. Figure there is a way > tho. ;-) > > My question is this. Do some of you have scripts that are fairly simple > to figure out that does something similar to this that you can share? > I'm wanting to check some scripts that are known to work and figure out > how they work. I tried to look at Frank's checksum script but that > thing is HUGE. I was lost before I even needed to scroll down. Some > fairly small and simple scripts may give me enough to figure out how to > do what I want to do and understand it as well. If someone has a script > that is more like a example script, where the words used explain what > the script is doing and why it is laid out a certain way, that would be > really nice. > > The book is nice. It's just not what I'm looking for. I may try to > find something cheap on Ebay. > > Thanks. > > Dale > > :-) :-) > Don't listen to me.... In bash scripting, what purpose do { and } serve? In Bash scripting, { and } have several purposes depending on the context: Command Grouping: Used to group multiple commands into a single unit. This is useful for executing a set of commands in a specific context, such as within an if statement or redirecting output. Example: bash { echo "Hello"; echo "World"; } > output.txt This redirects both echo commands' output to output.txt. Brace Expansion: Allows generating multiple strings based on a pattern, often used for file and directory creation. Example: bash echo {A,B,C} Outputs: A B C Array Definition (in newer versions of Bash): Used to define an array or reference elements within an array. Example: bash my_array=3D(one two three) echo ${my_array[1]} # Outputs "two" Function Definitions: Used when defining a function in Bash. Example: bash my_function() { echo "Hello from the function!" } my_function Would you like to see how {} interacts with networking-related tasks? Maybe for automation with server configurations or scripting remote access methods?