Reputation: 528
I have a directory containing files with name starting with timestamp eg 20170102065744.get . Some of these files contain a number as a pattern eg 456787.I need to move only those files whose names match 201701* and have the number pattern 456787 from the original directory to another directory.
The OS is Sun Solaris Unix
Upvotes: 0
Views: 1772
Reputation: 528
I was able to achieve it using a shell script using grep based on idea suggested by @Bogdan
#!/bin/bash
for i in 'grep -l 456787 src_dir/201701*`
do
mv $i destn_dir/
done
Upvotes: 0
Reputation: 4529
Not sure about the correct syntax on solaris os but a linux system you might be able to achieve that using something like this (assuming your current shell prompt location is in that folder containing the files)
for i in `find . -type f -name "*201701*" | grep 456787 `; do mv $i move_to_folder/; done
Upvotes: 1