Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash store file in array

# 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
Comment

bash load file as array

# Basic syntax:
while IFS= read line; do
	FILE_IN_ARRAY+=("$line")
done </path/to/your/file.txt
# Where:
#	- this site explains arrays helpfully: 
#		https://linuxize.com/post/bash-arrays/
Comment

bash read file into array

readarray -t arr <file
Comment

PREVIOUS NEXT
Code Example
Shell :: install pip linux 
Shell :: how to git clone from a specific branch git 
Shell :: laravel install bootstrap 5 
Shell :: bash for loop multiple commands one line 
Shell :: copy files out of docker 
Shell :: conda install keyboard 
Shell :: git stash with a message 
Shell :: linux mount ntfs as read write 
Shell :: how to install sshpass on mac 
Shell :: convert a WSL 1 distro to WSL 2 
Shell :: make git use a ssh key 
Shell :: env variables list ubuntu 
Shell :: refresh prometheus configuration 
Shell :: git push -u rejected 
Shell :: nuxt init 
Shell :: git specify ssh key for repo 
Shell :: install mysql in debian 
Shell :: how to restart x window manager in ubuntu 18.04 
Shell :: linux killall python 
Shell :: bash single vs double quotes 
Shell :: 10250: connect: no route to host kubernetes 
Shell :: install postman desktop ubuntu 
Shell :: how to install cuda on ubuntu 
Shell :: how to revert a merge locally 
Shell :: crontab save 
Shell :: How install packages from package.tar.gz on rstudio 
Shell :: linux env 
Shell :: conda install python image library 
Shell :: env variable for access key and secret key in terraform 
Shell :: iptables remove docker rules 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =