“bash membaca file ke variabel” Kode Jawaban

Baca file menggunakan skrip shell

#!/bin/bash
input="/path/to/txt/file"
while IFS= read -r line
do
  echo "$line"
done < "$input"
Thankful Tapir

bash membaca file ke variabel

# Basic syntax:
FILELINES=`cat your_file.txt`

# Example usage:
# Say you have a file "your_file.txt" containing the following sample names
# and you want to iterate over them in a bash script:
SAMPLE1
SAMPLE2
SAMPLE3
# The bash script would look like:
SAMPLES = `cat your_file.txt`
for SAMPLE in $SAMPLES; do
	echo $SAMPLE
done
Charles-Alexandre Roy

Jawaban yang mirip dengan “bash membaca file ke variabel”

Pertanyaan yang mirip dengan “bash membaca file ke variabel”

Lebih banyak jawaban terkait untuk “bash membaca file ke variabel” di Shell/Bash

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya