help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] if exist


From: Val Krem
Subject: [Help-bash] if exist
Date: Sat, 13 May 2017 01:21:32 +0000 (UTC)

Hi all,


I have list of files in a given folder  and some of these files are ending with 
any digit(starting from 1 up to may be  9 or more). My aim is if a file name is 
ending with any digit number then I want copy it to other folder and suppress 
the error message generated if the file does not exist in the folder.

Sample of list of  files 
xbx1.txt1
xby2.txt2
xcx3.txt3
xxx1.txt4
xxy1.txt5

Below is my attempt.

#! /bin/bash 

dat0=/data/val1
dat1=/data/val2
shopt -s extglob
cd ${dat0}
xc=$(ls x*'.'txt{1..10})
echo $xc

for i in $(xc);do
    if [  ${xc}  ];then
       cp ${xc} $dat1
    fi
done

But did not work.
Can some one help me out?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]