[SOLVED] Format Linux terminal output to facilitate linked index in Obsidian.

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Post Reply
TaraThomasNow
Level 1
Level 1
Posts: 15
Joined: Mon Mar 04, 2024 11:41 pm
Location: Newcastle, Australia

[SOLVED] Format Linux terminal output to facilitate linked index in Obsidian.

Post by TaraThomasNow »

Yeah, it's a bit of a crossover ask here so please feel free to direct me another section of forum/ show me the door.

Desired outcome:
Learn how to format the terminal output in a very specific syntax that I can drop into an Obsidian note. With a command? Or other smart geek thing?

More details below the System Info (which I don't know is relevant in this context but I'm following the rules, bro)


Linux Version:
Cinnamon 21.3 Edge

System Information;

Code: Select all

System:
  Kernel: 6.5.0-21-generic x86_64 bits: 64 compiler: N/A Desktop: Cinnamon 6.0.4 tk: GTK 3.24.33
    wm: muffin vt: 7 dm: LightDM 1.30.0 Distro: Linux Mint 21.3 Virginia base: Ubuntu 22.04 jammy
Machine:
  Type: Laptop System: Acer product: Aspire E5-523G v: V1.05 serial: <superuser required>
  Mobo: Acer model: Wasp_SR v: V1.05 serial: <superuser required> UEFI-[Legacy]: Insyde v: 1.05
    date: 05/23/2016
Battery:
  ID-1: BAT1 charge: 20.6 Wh (100.0%) condition: 20.6/41.4 Wh (49.8%) volts: 16.9 min: 14.8
    model: PANASONIC AS16A5K type: Li-ion serial: <filter> status: Full
CPU:
  Info: dual core model: AMD A9-9410 RADEON R5 5 COMPUTE CORES 2C+3G bits: 64 type: MCP
    smt: <unsupported> arch: Excavator rev: 0 cache: L1: 192 KiB L2: 2 MiB
  Speed (MHz): avg: 3493 min/max: 1400/2900 boost: enabled cores: 1: 3493 2: 3493
    bogomips: 11578
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
  Device-1: AMD Stoney [Radeon R2/R3/R4/R5 Graphics] vendor: Acer Incorporated ALI driver: amdgpu
    v: kernel ports: active: eDP-1 empty: DP-1,HDMI-A-1 bus-ID: 00:01.0 chip-ID: 1002:98e4
    class-ID: 0300
  Device-2: AMD Sun XT [Radeon HD 8670A/8670M/8690M / R5 M330 M430 Radeon 520 Mobile]
    vendor: Acer Incorporated ALI driver: radeon v: kernel pcie: speed: 2.5 GT/s lanes: 4
    bus-ID: 01:00.0 chip-ID: 1002:6660 class-ID: 0380
  Device-3: Chicony HD WebCam type: USB driver: uvcvideo bus-ID: 2-1:2 chip-ID: 04f2:b573
    class-ID: 0e02
  Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: ati,radeon
    unloaded: amdgpu,fbdev,modesetting,vesa gpu: amdgpu display-ID: :0 screens: 1
  Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.2x8.0") s-diag: 414mm (16.3")
  Monitor-1: eDP res: 1366x768 hz: 60 dpi: 101 size: 344x194mm (13.5x7.6") diag: 395mm (15.5")
  OpenGL: renderer: STONEY (stoney LLVM 15.0.7 DRM 3.54 6.5.0-21-generic)
    v: 4.5 Mesa 23.2.1-1ubuntu3.1~22.04.2 direct render: Yes
Audio:
  Device-1: AMD driver: snd_hda_intel v: kernel bus-ID: 00:01.1 chip-ID: 1002:15b3 class-ID: 0403
  Device-2: AMD Family 15h Audio vendor: Acer Incorporated ALI driver: snd_hda_intel v: kernel
    bus-ID: 00:09.2 chip-ID: 1022:157a class-ID: 0403
  Sound Server-1: ALSA v: k6.5.0-21-generic running: yes
  Sound Server-2: PulseAudio v: 15.99.1 running: yes
  Sound Server-3: PipeWire v: 0.3.48 running: yes
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: Acer Incorporated ALI
    driver: r8169 v: kernel pcie: speed: 2.5 GT/s lanes: 1 port: 3000 bus-ID: 02:00.1
    chip-ID: 10ec:8168 class-ID: 0200
  IF: enp2s0f1 state: down mac: <filter>
  Device-2: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter vendor: Lite-On
    driver: ath10k_pci v: kernel pcie: speed: 2.5 GT/s lanes: 1 bus-ID: 03:00.0 chip-ID: 168c:0042
    class-ID: 0280
  IF: wlp3s0 state: up mac: <filter>
  IF-ID-1: docker0 state: down mac: <filter>
Bluetooth:
  Device-1: Lite-On Qualcomm Atheros QCA9377 Bluetooth type: USB driver: btusb v: 0.8
    bus-ID: 1-1.3:4 chip-ID: 04ca:3015 class-ID: e001
  Report: hciconfig ID: hci0 rfk-id: 0 state: up address: <filter> bt-v: 2.1 lmp-v: 4.1
    sub-v: 25a hci-v: 4.1
Drives:
  Local Storage: total: 1.94 TiB used: 156.35 GiB (7.9%)
  ID-1: /dev/sda vendor: Seagate model: ST2000LM003 HN-M201RAD size: 1.82 TiB speed: 6.0 Gb/s
    type: HDD rpm: 5400 serial: <filter> rev: 0001 scheme: GPT
  ID-2: /dev/sdb vendor: LITE-ON model: CV3-8D128 size: 119.24 GiB speed: 6.0 Gb/s type: SSD
    serial: <filter> rev: 202 scheme: GPT
Partition:
  ID-1: / size: 116.32 GiB used: 45.48 GiB (39.1%) fs: ext4 dev: /dev/sdb3
  ID-2: /boot/efi size: 512 MiB used: 6.1 MiB (1.2%) fs: vfat dev: /dev/sdb2
Swap:
  ID-1: swap-1 type: file size: 2 GiB used: 256 KiB (0.0%) priority: -2 file: /swapfile
USB:
  Hub-1: 1-0:1 info: Full speed or root hub ports: 2 rev: 2.0 speed: 480 Mb/s chip-ID: 1d6b:0002
    class-ID: 0900
  Hub-2: 1-1:2 info: Advanced Micro Devices Root Hub ports: 4 rev: 2.0 speed: 480 Mb/s
    power: 100mA chip-ID: 0438:7900 class-ID: 0900
  Device-1: 1-1.1:3 info: Logitech Unifying Receiver type: Keyboard,Mouse
    driver: logitech-djreceiver,usbhid interfaces: 2 rev: 2.0 speed: 12 Mb/s power: 98mA
    chip-ID: 046d:c534 class-ID: 0301
  Device-2: 1-1.3:4 info: Lite-On Qualcomm Atheros QCA9377 Bluetooth type: Bluetooth
    driver: btusb interfaces: 2 rev: 2.0 speed: 12 Mb/s power: 100mA chip-ID: 04ca:3015
    class-ID: e001
  Hub-3: 2-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0 speed: 480 Mb/s
    chip-ID: 1d6b:0002 class-ID: 0900
  Device-1: 2-1:2 info: Chicony HD WebCam type: Video driver: uvcvideo interfaces: 2 rev: 2.0
    speed: 480 Mb/s power: 500mA chip-ID: 04f2:b573 class-ID: 0e02
  Hub-4: 3-0:1 info: Super-speed hub ports: 4 rev: 3.0 speed: 5 Gb/s chip-ID: 1d6b:0003
    class-ID: 0900
Sensors:
  System Temperatures: cpu: 52.0 C mobo: N/A
  Fan Speeds (RPM): N/A
  GPU: device: radeon temp: 44.0 C device: amdgpu temp: 51.0 C
Repos:
  Packages: 2213 apt: 2199 flatpak: 14
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list
    1: deb http: //packages.linuxmint.com virginia main upstream import backport
    2: deb http: //archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
    3: deb http: //archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
    4: deb http: //archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
    5: deb http: //security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
  Active apt repos in: /etc/apt/sources.list.d/spotify.list
    1: deb http: //repository.spotify.com stable non-free
Info:
  Processes: 271 Uptime: 6h 7m wakeups: 1 Memory: 7.21 GiB used: 3.16 GiB (43.9%) Init: systemd
  v: 249 runlevel: 5 Compilers: gcc: 11.4.0 alt: 11/12 Client: Unknown python3.10 client
  inxi: 3.3.13

So far:
I'm super noob using the terminal. Doesn't get much noobier. AND even so I've managed to pipe meself a list of files in my local drive resource library

Code: Select all

ls -R /mnt/Data/Library > Index.txt
That gives me a great outputted list of all the files in that folder which was a fist pump for a basic b*tch like me...

BUT

I'd like to be able to format that list so that I can link each of those files within the notes in my Obsidian vault without painstakingly renaming every single thing. I'd like to learn to do this as quickly and simply as possible, because the index will require ongoing updating as I frequently drop files in there.

That is, I want the process to be quick & simple (but I appreciate that the learning how might take a minute!).

An example from the output looks like this;

Code: Select all

/mnt/Data/Library:
AFSA Alternative Family Systems Approach
Alexandra Solomon

/mnt/Data/Library/AFSA Alternative Family Systems Approach:
AlternativeFamilySystemsApproach-2021.pdf
Course hand out and bibliography Opening the realtionship (AFSA) online course.pdf
SexHx FORM - 2020.pdf

/mnt/Data/Library/Alexandra Solomon:
Alexandra Solomon_ Overfunctioner Underfunctioner Podcast.docx
Alexandra Solomon_ Overfunctioner Underfunctioner Podcast.mp3
Mission Statement for Couples (Can I Trust You_) SOLOMON.docx
This is a small sample of a substantially larger library of assorted file types.

The format I'd like instead is;


For the list in /mnt/Data/Library
the folder name within double square brackets; \[[Alexandra Solomon]]

For the FILES in each folder

\[Local file - Dr Charles Hoffe - Lytton BC Video Interview](<file:///Y:\Covid\Canadian Doctor Defies Gag Order - Tells Public How Moderna COVID Shots Killed and Disabled Patients-vdil0d.mp4>)

That is, ["Local file - file name"](<“file:///”"file path and name">

So in my example: \[Local file - Alexandra Solomon_Overfunctioner Underfunctioner Podcast](<file:////mnt/Data/Library/Alexandra Solomon/Alexandra Solomon_Overfunctioner Underfunctioner Podcast.mp3>)

I have changed the backslashes to forward slashes as I believe (from reading a different forum) that the backslashes only work in a Windows environment.

Thanks in advance you glorious brainiacs!

Oh, I should also say that I am highly adept at following instructions and doing a bunch of troubleshooting myself, BUT I am new so require/request step by step instructions. Like, imagine you've never seen any of the GUI before, nor had any experience with any kind of coding, and have to teach someone every literal step. Because that's where I'm at.
Last edited by TaraThomasNow on Tue Mar 26, 2024 7:59 pm, edited 1 time in total.
TaraThomasNow
Level 1
Level 1
Posts: 15
Joined: Mon Mar 04, 2024 11:41 pm
Location: Newcastle, Australia

Re: Format Linux terminal output to facilitate linked index in Obsidian.

Post by TaraThomasNow »

Alright alright alright...
I made this way more complicated than it needed to be (which is 100% on brand for me).

I solved it, and am back to provide a solution (probs not "the" solution) for anyone else who wants to do this exact same thing.

Step 1 - go to ChatGPT and ask it to do the thing.
Step 2 - tweak the instructions til you get the correct results.
Step 3 - instruct ChatGPT to "write an instruction list for me so that if I put it into ChatGPt, or give to someone else, the desired output is clear". I love this particular step because I can get much more specificity in the instruction which makes it replicable (and teaches me how to interact in a clearer way both here and in other forums".

Here are the instructions:


1. Formatted List Instructions:
Start with the directory path "/mnt/Data/Library:".
  • List each item with double square brackets and no bullets.
Example:

Code: Select all

    /mnt/Data/Library:
[[AFSA Alternative Family Systems Approach]]
[[Alexandra Solomon]]    

2. Formatted File Instructions:

For each file, use the following format:

Code: Select all

  - [Local file - File Name](<file:///filepath/filename>)   
  • Replace "File Name" with the actual name of the file.
    Replace "filepath/filename" with the actual file path and name.
Example:

Code: Select all

- [Local file - AlternativeFamilySystemsApproach-2021.pdf](<file:////mnt/Data/Library/AFSA Alternative Family Systems Approach/AlternativeFamilySystemsApproach-2021.pdf>)
- [Local file - Course hand out and bibliography Opening the realtionship (AFSA) online course.pdf](<file:////mnt/Data/Library/AFSA Alternative Family Systems Approach/Course hand out and bibliography Opening the realtionship (AFSA) online course.pdf>)
- [Local file - SexHx FORM - 2020.pdf](<file:////mnt/Data/Library/AFSA Alternative Family Systems Approach/SexHx FORM - 2020.pdf>)
Anyways, hope this makes someone else feel as wildly jubilant as I do!
Post Reply

Return to “Scripts & Bash”