Linked Questions
133 questions linked to/from Looping through the content of a file in Bash
1 vote
1 answer
217 views
inline bash for-loops and greps [duplicate]
-Edit- This isn't a duplicate because I'm using one file to compare another everything I found on SO is looping through one file without an input file to compare. A list of filenames.csv looks like ...
0 votes
1 answer
168 views
Alternatives for heredocs in bashscripts? External templating? [duplicate]
I currently use many heredocs in bash scripts. These heredocs contain bash variables, e.g. ${MY_VAR}, which are substituted as the script executes and the heredoc is read. Some of these heredocs have ...
0 votes
1 answer
85 views
Opening pdfs from a list file which contains paths to pdfs [duplicate]
I have a list file of selected pdfs (each line contains a path to pdf). These pdfs are located in different directories which are several thousands in total. I am very new to using bash and struggling ...
-2 votes
1 answer
103 views
How to call a string by string from a file to use in for loop in linux shell scripting [duplicate]
I have a below sql query. select * from table where name in ('${name}); I have a requirement to automate this as here i need to pass the string value name from txt file. The text file contains the ...
1 vote
0 answers
94 views
for loop to be used with readpst library [duplicate]
I am having an issue with for loop on centos: I am trying to convert a lot of .pst files using readpst library: the following works fine: /bin/readpst -o /destination_directory -M -S -e -D /...
0 votes
3 answers
73 views
awk, sed, for in bash: Print "Hello" + Name [duplicate]
I have a list.csv with the following content: "date";"Mr. Green Tree" "date";"Mr. Red Apple" "date";"Mr. Blue Car" I use awk + sed to get ...
0 votes
1 answer
86 views
How to read from a file in bash script? [duplicate]
I have a simple bash script below that outputs into a file threat info from the domain 1605158521.rsc.cdn77.org. The domain is read from B1Dossier. #!/bin/bash baseurl=https://csp.infoblox.com ...
0 votes
0 answers
73 views
echo stdin line by line into file [duplicate]
I am trying to automate setting up Private Key Authentication for SSH. Not sure how to achieve my desired result. I need to look stdin line by line into a file. key(){ read -p "Paste Your Private ...
0 votes
2 answers
51 views
Entering lines into password promt [duplicate]
For a uni-assignment I need to write a while-loop for BASH-shell (on windows) that tries different passwords line by line from a given .txt-file and enter them to unzip a given .zip-Archive. I know ...
0 votes
0 answers
28 views
For Loop to read a file line by line [duplicate]
for word in $(cat link_name.list); do echo "$word"; done The for loop does not read contents line by line but as a single line. Not sure why a while loop is preferred to do this?
0 votes
0 answers
24 views
while read eliminates leading whitespace [duplicate]
I try to print lines of a text which begin with a # I need only these lines, but not the ones with [[:whitespace:]]# $ cat text.txt # no whitespace in front of # # 3 whitespace in front of # # ...
0 votes
0 answers
15 views
Access column element of each row bash/shell script [duplicate]
I have the following array 4000 85.81 20 4100 70 17.5 1200 83.233 22.5 The first column shows station ID, second longitude, and third latitude. I wish to read each rows in bash pertains to say,...
306 votes
9 answers
285k views
A variable modified inside a while loop is not remembered
In the following program, if I set the variable $foo to the value 1 inside the first if statement, it works in the sense that its value is remembered after the if statement. However, when I set the ...
207 votes
7 answers
258k views
How to process each output line in a loop?
I have a number of lines retrieved from a file after running the grep command as follows: var=`grep xyz abc.txt` Let’s say I got 10 lines which consists of xyz as a result. Now I need to process ...
168 votes
9 answers
57k views
Useless use of cat?
This is probably in many FAQs - instead of using: cat file | command (which is called useless use of cat), correct way supposed to be: command < file In the 2nd, "correct" way - OS does not have ...