- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- File cp script - questions about grep statement
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2006 08:20 AM
02-09-2006 08:20 AM
File cp script - questions about grep statement
### flat file ### -- App 2 Hire
appid empno hire date
123456789|14522|01/31/2006|
987654321|14503|01/20/2006|
000111123|14504|01/19/2006|
# I am looking at the file name within the file system in the first FOR statement to determine the appid, this portion works, however the second FOR statement pulls all values from the $2 field from the flat file,
I want to define it so if a file exists and the associate "appid" has an "empno" then I copy the file.. I believe I am missing something in the second for loop and need a few extra sets of eyes to give an idea of what the heck i'm missing.. Any thought appreciated..
Rex M
export p1=/upload_resumes/
export p2=/upload_resumes/backup/
export wst=/wst-docs/applicant/
export mps=/mps-docs/mps-docs/applicant/
export esu=/esu-docs/applicant/
export plv=/plv-docs/
export wste=/wst-docs/employee/
export mpse=/mps-docs/mps-docs/employee/
export esue=/esu-docs/employee/
export plve=/plv-docs/employee/
echo NEW
for fn in `ls /upload_resumes/`
do
for dist in `echo $fn |awk '{print substr($1,1,3)}'`
# DISTRICT SPECIFIC INFORMATION
do
export dist
case $dist in
wst)
export distpath="$wst"
export distpathe="$wste"
;;
mps)
export distpath="$mps"
export distpathe="$mpse"
;;
esu)
export distpath="$esu"
export distpathe="$esue"
;;
plv)
export distpath="$plv"
export distpathe="$plve"
;;
*)
;;
esac
for appid in `echo $fn |awk -F_ '{print $2}'`
do
echo FILENAME: $fn
export appid
echo $appid
export source="$p1$fn"
echo $source
for empno in `grep -e "$appid" /tmp/"$dist"apphire.txt|awk -F"|" '{print $2}' `
do
export empno
echo $empno
echo $appid
done
read
if [ -n "$empno" ]
then
export destination="$distpathe$empno/$fn"
echo export destination="$distpathe$empno/$fn"
if [ -d "$distpathe$empno" ]
then
cp -f $source $destination
else
mkdir $distpathe$empl_no
cp -f $source $destination
fi
else
echo EMPL_NO has no valued position
fi
#END OF APPID SPECIFIC INFORMATION
done
#END OF DISTRICT SPECIFIC FILE MANIPULATION
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2006 08:23 AM
02-09-2006 08:23 AM
Re: File cp script - questions about grep statement
export destination=/mps-docs/mps-docs/employee/14511/mpsplus_11_1.pdf
FILENAME: mpsplus_11_2.pdf
11
/upload_resumes/mpsplus_11_2.pdf
14501
11
14511
11
export destination=/mps-docs/mps-docs/employee/14511/mpsplus_11_2.pdf
FILENAME: mpsplus_1_1.pdf
1
/upload_resumes/mpsplus_1_1.pdf
14522
1
14503
1
14504
1
14383
1
14501
1
14510
1
14502
1
14511
1
export destination=/mps-docs/mps-docs/employee/14511/mpsplus_1_1.pdf
FILENAME: mpsplus_507745863_2.pdf
507745863
/upload_resumes/mpsplus_507745863_2.pdf
14511
507745863
export destination=/mps-docs/mps-docs/employee/14511/mpsplus_507745863_2.pdf
FILENAME: mpsplus_5_1.pdf
5
/upload_resumes/mpsplus_5_1.pdf
14522
5
14503
5
14504
5
14383
5
14501
5
14510
5
14502
5
14511
5
^[[A
export destination=/mps-docs/mps-docs/employee/14511/mpsplus_5_1.pdf
FILENAME: mpsplus_7_1.doc
7
/upload_resumes/mpsplus_7_1.doc
14501
7
14502
7
14511
7
export destination=/mps-docs/mps-docs/employee/14511/mpsplus_7_1.doc
FILENAME: mpsplus_9_1.doc
9
/upload_resumes/mpsplus_9_1.doc
14504
9
14501
9
14510
9
14502
9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2006 08:27 AM
02-09-2006 08:27 AM
Re: File cp script - questions about grep statement
grep -w
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2006 08:29 AM
02-09-2006 08:29 AM
Re: File cp script - questions about grep statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2006 08:51 AM
02-09-2006 08:51 AM