0

I have a task to merge three files in linux, so i used awk to achieve this task. hostsfiles is a variable which has test.txt test1.txt and test3.txt

awk 1 {{ hostsfiles | join(' ') }}

I get below error. How do i avoid the error when any one of the file is missing

fatal: cannot open file `/test.txt' for reading (No such file or directory
celcoprab
  • 43
  • 2
  • 3
  • 8
  • Look for files with e.g. `find` and remove the ones that don't exist from your list prior to launching your command. – Zeitounator Dec 23 '20 at 13:36
  • How about using cat command to merge all your files? ```cat $hostfsfiles > targetfile``` If any file is not present, it will be automatically ignored and it's output be printed to console. – BarathVutukuri Jun 19 '21 at 06:06

0 Answers0