Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hello, I am creating a job mana

Status
Not open for further replies.

AdamCoombs

Technical User
May 22, 2002
51
GB
hello,

I am creating a job management system and need to create a directory structure based on the job number..
for example..
job number: 12345678 (always 8 digits)
the directory structure would be
/jobs/12/12345/12345678
Question is...how do i pull out the first 2 digits and then the first 5 digits of a job number.
I will be be searching a plain text file for the job number.

thanks
Adam
 
How about
Code:
$ a="12345678"
$ b=`echo $a|awk '{print substr($0,1,2)}'`
$ echo $b
12
 
echo '1234578' | sed -n -e 's/^\(..\)\(...\)\(.*\)/\1 \1\2 \1\2\3/p' | read FIRST SECOND THIRD

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
#!/bin/ksh
job='12345678'

path2jobs=&quot;/jobs/$(echo &quot;${job}&quot; | sed -n -e 's:^\(..\)\(...\)\(.*\):\1/\1\2/\1\2\3:p')

echo &quot;path2jobs->[${path2jobs}]&quot;

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
ooops -sorry:

#!/bin/ksh
job='12345678'

path2jobs=&quot;/jobs/$(echo ${job} | sed -n -e 's:^\(..\)\(...\)\(.*\):\1/\1\2/\1\2\3:p')&quot;

echo &quot;path2jobs->[${path2jobs}]&quot;

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
$ a=&quot;12345678&quot;
$ b=`echo $a|cut -c-5`
$ c=`echo $a|cut -c-2`
$ echo /jobs/$c/$b/$a
/jobs/12/12345/12345678
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top