<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Kubuntu Forums - Coding/Scripting</title>
		<link>https://www.kubuntuforums.net/</link>
		<description>Get help writing code or post new code for others to use</description>
		<language>en</language>
		<lastBuildDate>Wed, 28 Oct 2026 19:04:02 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>images/misc/rss.png</url>
			<title>Kubuntu Forums - Coding/Scripting</title>
			<link>https://www.kubuntuforums.net/</link>
		</image>
		<item>
			<title>awk/sed/whatever bash question</title>
			<link>https://www.kubuntuforums.net/forum/general/miscellaneous/coding-scripting/694628-awk-sed-whatever-bash-question</link>
			<pubDate>Tue, 06 Oct 2026 19:51:09 GMT</pubDate>
			<description>I wrote and maintain a set of Dolphin Service Menus to allow some btrfs functionality to be accessible from Dolphin. 
 
I am adding the ability to...</description>
			<content:encoded><![CDATA[I wrote and maintain a set of Dolphin Service Menus to allow some btrfs functionality to be accessible from Dolphin.<br />
<br />
I am adding the ability to determine if a &quot;btrfs send|btrfs receive&quot; operation was successful. The success or failure is is indicated by two items retrievable from &quot;btrfs su show&quot;. They are &quot;Received UUID:&quot; followed by a UUID and &quot;FLAGS:&quot; followed by &quot;readonly&quot;. <b>Both</b> entries are <b>only</b> set if the send|receive operation completes successfully.<br />
<br />
One uses the &quot;btrfs su show&quot; action to see the full list of subvolume information, which looks like this:<br />

<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	
	<pre class="bbcode_code" style="max-height:calc(30 *  + 12px + 20px);">sudo btrfs su show @KDEneon_backup
Name:                   @KDEneon_backup
UUID:                   00983575-f97d-d942-9537-f4c8c29bc77a
Parent UUID:            0bef4f24-2620-7443-84d2-43c82a79e690
Received UUID:          16716210-06d4-ea42-9048-7449068cb643
Creation time:          2026-10-06 05:39:35 -0400
Subvolume ID:           2246
Generation:             14825
Gen at creation:        14820
Parent ID:              5
Top level ID:           5
Flags:                  readonly
Send transid:           2145521
Send time:              2026-10-06 05:39:35 -0400
Receive transid:        14821
Receive time:           2026-10-06 05:39:36 -0400
Snapshot(s):
Quota group:            n/a​</pre>
</div>If the send|receive operation fails, the fields after &quot;Received UUID&quot; and &quot;Flags:&quot; have a dash in them instead of the above.<br />
<br />
<b>The question: Is there a preferred or &quot;better&quot; way to extract this information from the above output?</b><br />
<br />
Currently, I'm using:<br />

<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	
	<pre class="bbcode_code" style="max-height:calc(30 *  + 12px + 20px);">RECEIVED_UUID=`sudo -S btrfs su sh $SOURCE | awk 'NR &gt;4 &amp;&amp; NR&lt;=5 {print $3}'`
READONLY_FLAG=`sudo -S btrfs su sh $SOURCE | awk 'NR &gt;11 &amp;&amp; NR&lt;=12 {print $2}'`</pre>
</div>$SOURCE is the full path and filename of the selected subvolume. The above <b>awk</b> statements retrieve the Received UUID and &quot;readonly&quot; from Flags, and it works.<br />
<br />
I then use a conditional &quot;if - or&quot; to check for the dash instead of anything else:
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	
	<pre class="bbcode_code" style="max-height:calc(30 *  + 12px + 20px);">if &#91;&#91; $RECEIVED_UUID == '-' || $READONLY_FLAG == '-' &#93;&#93;; then</pre>
</div>​so if either entry is not set, the script reports that it failed or wasn't a &quot;sent&quot; snapshot.<br />
<br />
I feel like there must be a handful of other ways to scrape the info. Mostly, I'm just curious, but having &quot;solid&quot; code is always a good idea.<br />
<br />
Thoughts?]]></content:encoded>
			<category domain="https://www.kubuntuforums.net/forum/general/miscellaneous/coding-scripting">Coding/Scripting</category>
			<dc:creator>oshunluvr</dc:creator>
			<guid isPermaLink="true">https://www.kubuntuforums.net/forum/general/miscellaneous/coding-scripting/694628-awk-sed-whatever-bash-question</guid>
		</item>
	</channel>
</rss>
