I have a directory containing files as given below
PALK.BHZ.2010.10.31.12.23.42.350.10.sac.
PALK.BHZ.2010.10.31.12.23.42.350.10.sac..dsp
PALK.BHZ.2010.11.08.07.37.10.140.00.sac.
PALK.BHZ.2010.11.08.07.37.10.140.00.sac..dsp
PALK.BHZ.2010.11.08.07.37.10.140.10.sac.
PALK.BHZ.2010.11.08.12.28.34.430.00.sac.
PALK.BHZ.2010.11.08.12.28.34.430.10.sac.
I want to mv files of a similar name which have a different extension.
Like from above files I want to move below-given files to a new location.
PALK.BHZ.2010.10.31.12.23.42.350.10.sac.
PALK.BHZ.2010.10.31.12.23.42.350.10.sac..dsp
PALK.BHZ.2010.11.08.07.37.10.140.00.sac.
PALK.BHZ.2010.11.08.07.37.10.140.00.sac..dsp
So far I have tried below code, but the problem still remains
for file in *sac.; do
[ -f "$file" ] || continue
[ ! -e "${file%%.*}.dsp" ] && mv "$file" /home/gar
done
PALK.BHZ.2010.10.31.12.23.42.350.10.sac.
PALK.BHZ.2010.10.31.12.23.42.350.10.sac..dsp
PALK.BHZ.2010.11.08.07.37.10.140.00.sac.
PALK.BHZ.2010.11.08.07.37.10.140.00.sac..dsp
PALK.BHZ.2010.11.08.07.37.10.140.10.sac.
PALK.BHZ.2010.11.08.12.28.34.430.00.sac.
PALK.BHZ.2010.11.08.12.28.34.430.10.sac.
I want to mv files of a similar name which have a different extension.
Like from above files I want to move below-given files to a new location.
PALK.BHZ.2010.10.31.12.23.42.350.10.sac.
PALK.BHZ.2010.10.31.12.23.42.350.10.sac..dsp
PALK.BHZ.2010.11.08.07.37.10.140.00.sac.
PALK.BHZ.2010.11.08.07.37.10.140.00.sac..dsp
So far I have tried below code, but the problem still remains
for file in *sac.; do
[ -f "$file" ] || continue
[ ! -e "${file%%.*}.dsp" ] && mv "$file" /home/gar
done