Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

shell iterate over lines in variable

#!/bin/bash
#Try to iterate over each line
echo "For loop:"
for item in $list
do
        echo "Item: $item"
done
#Output the variable to a file
echo -e $list > list.txt

#Try to iterate over each line from the cat command
echo "For loop over command output:"
for item in `cat list.txt`
do
        echo "Item: $item"
done
Comment

PREVIOUS NEXT
Code Example
Shell :: how to fast mouse scrolling in ubuntu 20.04 
Shell :: bash grep all after match 
Shell :: how to set two wallpaper in ubuntu 
Shell :: git remove all tracked files after add in git ignoore 
Shell :: git reset staged files 
Shell :: blame in github 
Shell :: remove all gems installed 
Shell :: install zipkin docker 
Shell :: sudoers file location 
Shell :: Git config --list to list all the settings 
Shell :: bash assigning to new array 
Shell :: windows terminal 
Shell :: gatsby plugin image 
Shell :: tailwindcss 
Shell :: curl save file 
Shell :: see cpu usage terminal linux 
Shell :: redis: command not found 
Shell :: rmdir command 
Shell :: default .gitignore file 
Shell :: bash remove string from string 
Shell :: Bash script Array + For loop 
Shell :: push amended commit 
Shell :: kali linux download 
Shell :: secure shell 
Shell :: git bash in cmd 
Shell :: linux ls show full path 
Shell :: npm install 
Shell :: ssh into directory 
Shell :: git list untracked files 
Shell :: gzip folder with tar and exclude directories 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =