K
K
KaliUser2022-03-06 16:50:12
bash
KaliUser, 2022-03-06 16:50:12

How to assign data from a file to a variable?

For example,
there is a data.txt file that says (123456)

I need to assign this data to the $dat variable

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Karabanov, 2022-03-06
@KaliUser

#!/bin/bash

dat=$(cat data.txt)
echo "$dat"

D
Dr. Bacon, 2022-03-06
@bacon

I watch mom's coolhazers don't even try to google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question