Help with taking variable of for loop in textfile

Hi,

I am new to unix/linux scripting.
I have a text file, listlib.txt where the content:

lib1_23
lib34_a
ab_li_lab

I need to generate a file ( .log ) of each cell. I am planning to create a ( .csh ) script that will have for loop with variable taken from listlib.txt. As for now, i have no automation script for this, generate .log one by one. Problem rises when i have many lib more than 30 libs.

The csh shell is notorious for behaving differently in scripts than it does interactively, is not standardized, and is usually not suggested as the best shell to use on UNIX and UNIX-like systems.

You don't say what is involved when you "generate a file", but maybe the following (which will work with any shell that uses the syntax described by the standards for shell behavior and works with many non- csh derived shells (such as ksh , bash , and several other shells based on Bourne shell syntax) will give you an idea of how to start:

#!/bin/ksh
while read -r log
do	touch "$log.log"
done < listlib.txt

Hi, I am sorry but I don't quite understand on the code. I tried the code but it stated:

while: Expression Syntax.

directory (liblist.txt):
user/mmaz/liblist.txt

directory (test3.csh):
user/mmaz/lib/test.csh

My rough idea for test3.csh:

   
for each lib in liblist.txt gen_lib_log $lib
 end for
 

So, the expected output will be in user/mmaz/log/, where the command will generate the log automatically.
e.g:

user/mmaz/log/lib1_23.log

Save this as test3.sh

#!/bin/sh
while read lib
do
  echo "lib $lib, logfile $lib.log"
  {
  # now output is redirected to the logfile
  echo  "$lib.log created `date`"
  } > "$lib.log"
done < listlib.txt

Make this executable with the command

chmod +x test3.sh

And run it with

./test3.sh

You will find the logfiles created for each library.

If your working command line shell is already csh then make sure that what you may think is a comment line starting with #! is included as the very first line without being indented. This is a special location and the #! described the code/shell to be using. That might make the suggestions work.

If not, can you show us the following output:-

uname -a
ps
echo $SHELL
pwd
ls -l test3.sh     # .... or whatever name you have given your code
cat test3.sh       # .... or whatever name you have given your code

Please wrap each in CODE tags which makes it much easier to read and preserves spacing for indenting or fixed-width data.

Thanks, in advance,
Robin