mardi 25 février 2020

Is there a way use a different command besides echo (do rm file) inside a conditional in unix

okay, I am reading the filenames from filelist.txt; for each line in filelist.txt I want to run a command lar -c.

To test my code I only want to run on the first line.

Here is my code

#!/bin/bash

fileList=/path/to/fileList.txt
count=1
if [[ $count == 1]]; then
  #getting the first line of the txt file
  line=$(sed "${count}q;d" $fileList)
  #execute my command
  do lar -c $line
fi;
count=`expr $count +1`

but when i try to execute my .sh file i get the following error

./ReadFilesFirstBatch.sh: line 34: syntax error near unexpected token `do'

I apologize I'm very new to bash coding but I want to figure this out!

Aucun commentaire:

Enregistrer un commentaire