Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1solQv-00DeCy-77 for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2024 15:08:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1solQu-00AVbm-D4 for pgsql-general@arkaria.postgresql.org; Thu, 12 Sep 2024 15:08:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1solQt-00AVZ9-WF for pgsql-general@lists.postgresql.org; Thu, 12 Sep 2024 15:08:32 +0000 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1solQr-000p07-2s for pgsql-general@postgresql.org; Thu, 12 Sep 2024 15:08:30 +0000 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5dc93fa5639so558936eaf.1 for ; Thu, 12 Sep 2024 08:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726153708; x=1726758508; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=qgalJ0LdgLL6HFvhydeq8AQZHaUbtTAkQWDiK1uE/ow=; b=eF29Ub8QV4J/NH2hINHa2tGulYXeDk4Zjvh4rbYMOK+6HbpA25BTArh8Lk6vAkK2kQ of6o9tbT9cpLBSRLX3XiL8qPh0jWOulALfw/cgNmX1xbmDu/nkIwmKfUcCpRHoxOKwpC H39cjsf4ipHIFUl1FW/bTmdwQBVkcfwFdqilrtrxuwUJ2nxu2JGunna21swmu44kPuSk LOTEsyXRYuO0D4qwN1/WJO+ykrYESK1v1ZHQhrqrmkNzTW31LEsSjZxlGLzCGBoypoAp pt8VVH7y+yslEaXPTAqy9O5U7qT58aPMcY3QHdc8pN27yAmAQR6PCxpP+e4kfG1ah4bR Y5mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726153708; x=1726758508; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qgalJ0LdgLL6HFvhydeq8AQZHaUbtTAkQWDiK1uE/ow=; b=nvqYaFhx88sQC2aCGgg+y4IKITGiGUTgOHyVrqjAk09sh5Pj1IdnaDaOJJvJjgGScP rNeZXNyxRDHPZeW1HfqXOSRSnrULJuFH2cTbpR88R5z637Mr7eXmkcmUzJ4+F+6JREO8 DMp0sbEKQoIhoaLRjJfQS1EmAt/i/LUnJBeg0r1sBI8VvqPBRbkdIaPjV6OUZV0iKYyx VfyySHjRApz+LdDTgTk+hfWhJLs5uWyPde+Uqwdlo1Esz2U7kevWj+AIS16IQw3ZtT8R oQmNK0WIoQ6Kg+UHNGz8vkXMGia9DSg97gYzTFwyxzSvpyAI7hnJ2n/nzUMSXVlnz19z ey7g== X-Gm-Message-State: AOJu0YzsAWujH+236DGn+6z1XeBve//UJwPx/OC2tWHixSXcWdcyF8nN LlDBw5Be2Sn654ajVqqTkOb4zp1ii8WncaeOJ/UIZmYB7MQXiXQIfa5Cg2tnHiCAbcMnp21HjTt kysNGIHE/zG0IvgHoFA4OjBAJUa1kK9sv X-Google-Smtp-Source: AGHT+IHa1rIhi82qojO7yzejOSJ1Y/ptu4/Jg6RyEQDn+mZv9odeUAHJNgWQrkR4etFMCYJDwIkUIMaxwzgb8F4VEn8= X-Received: by 2002:a05:6820:220f:b0:5e1:e8c4:fb00 with SMTP id 006d021491bc7-5e201455534mr1576377eaf.7.1726153707408; Thu, 12 Sep 2024 08:08:27 -0700 (PDT) MIME-Version: 1.0 From: Ron Johnson Date: Thu, 12 Sep 2024 11:08:16 -0400 Message-ID: Subject: Better way to process records in bash? To: pgsql-general Content-Type: multipart/alternative; boundary="0000000000008efa490621ed7a4e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008efa490621ed7a4e Content-Type: text/plain; charset="UTF-8" (This might be a bash question instead of a PG question, or it might be an A/B question.) I need to process table records in a bash script. Currently, I read them using a while loop and redirection. The table isn't that big (30ish thousand rows), and performance is adequate, but am always looking for "better". Here's the current code: declare f1 f3 f8 while IFS='|' read f1 f3 f8; do something f8 f3 f1 done < <(psql -XAt -c "select f1, f3, f8 from some.table_name;") -- Death to America, and butter sauce. Iraq lobster! --0000000000008efa490621ed7a4e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
(This might be a bash question instead of a PG question, o= r it might be an A/B question.)

I need to process table = records in a bash script.=C2=A0 Currently, I read them using a while loop a= nd redirection.=C2=A0 The table isn't that big (30ish thousand rows), a= nd performance is adequate, but am always looking for "better".

Here's the current code:
declare f1 f3 f8
while IFS=3D'|' read f1 f3 f8; d= o
=C2=A0 =C2=A0 something f8 f3 f1
done < <(psql -XAt -c "= select f1, f3, f8 from some.table_name;")

--
Death to America, and butter sauce.
Iraq lobster!
<= /div>
--0000000000008efa490621ed7a4e--