Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash store file lines in variable

# 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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #store #file #lines #variable
ADD COMMENT
Topic
Name
5+3 =