Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4475

Raspberry Pi OS • Reading the Content of a File to a Variable

$
0
0
Hi all


On my RPi I have a file called DeviceName.txt, which contains the name of the current RPi board.
This file contains a single word in it, without enters or spaces.

I need to read the content of this file to a variable,
and currently I am doing it like this:

Code:

export MachineID=$(cat DeviceName.txt)
It works,
but I am curious:
are there other ways to achieve it in addition to $(cat DeviceName.txt)?


Thank you

Statistics: Posted by spaceman5 — Fri Aug 30, 2024 3:14 pm — Replies 0 — Views 9



Viewing all articles
Browse latest Browse all 4475

Trending Articles