removing directory in an input file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers removing directory in an input file
# 1  
Old 06-02-2008
Data removing directory in an input file

Hi,

How can I removed the directory in the input file?

The script responsible for storing the report in an input file is this:

[I]while [ $i -lt "${#penfilename[*]}" ]
do

echo "penetration|${penfilename[i]}|${penfilenamedaterange}" >> ${OUT_DIR}/penrpt_emailfile.txt

(( i=i+1 ))

done


For the penfilename:

penfilename[i]=`echo ${OUTFILE}*"(${daterange})".csv`

Example of an input file is this:
penetration|/app/rms/rms/data/preticketing/penrpt/PenetrationReport_(MANN-6)_ByBuyer_(01-NOV-2007_01-NOV-2007).csv /app/rms/rms/data/preticketing/penrpt/PenetrationReport_(MANN-6)_ByVendor_(01-NOV-2007_01-NOV-2007).csv

Please help me!

I tried this script

penfilename[i]=`echo PenetrationReport*"(${daterange})".csv`

But its not working because it gives me an output of:

penetration|PenetrationReport*(01-NOV-2007_01-NOV-2007).csv.

My objective is to remove the output directory. This the result I'm expecting to have:

penetration|PenetrationReport_(MANN-6)_ByBuyer_(01-NOV-2007_01-NOV-2007).csv PenetrationReport_(MANN-6)_ByVendor_(01-NOV-2007_01-NOV-2007).csv

Thanks a lot!
# 2  
Old 06-02-2008
I didn't understand very well your script, but if you want to get rid of a directory name given a full pathname, try the command "basename", eg.:

Code:
basename "/app/rms/rms/data/preticketing/penrpt/PenetrationReport_(MANN-6)_ByVendor_(01-NOV-2007_01-NOV-2007).csv"

Will return:
Code:
PenetrationReport_(MANN-6)_ByVendor_(01-NOV-2007_01-NOV-2007).csv

# 3  
Old 06-05-2008
removing directory in an input file

Hi,

Thanks for your time..Smilie

But the problem is, this script basename "/app/rms/rms/data/preticketing/penrpt/PenetrationReport_(MANN-6)_ByVendor_(01-NOV-2007_01-NOV-2007).csv"
is not applicable because those where just the results of the generated report. I cannot directly changed that.

Okay..to better understand:

penfilename[i]=`echo ${OUTFILE}*"(${daterange})".csv` --> this script stores the generated reports. And the generated report is the records in the output file.

Since OUTFILE is consists of the output directory and PenetrationReport.(/app/rms/rms/data/preticketing/penrpt/ --> output directory and PenetrationReport)

I need to removed the output directory but retains the looping.

the responsible script for the looping is this:

[I][i]while [ $i -lt "${#penfilename[*]}" ]
do

echo "penetration|${penfilename}|${penfilenamedaterange}" >> ${OUT_DIR}/penrpt_emailfile.txt

(( i=i+1 ))

done


I hope you can really help me.. This is an urgent task I needed to submit. And I don't know much on unix..

Thanks a lot
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Removing punctuations from file input or standard input

Just started learning Unix and received my first assignment recently. We haven't learned many commands and honestly, I'm stumped. I'd like to receive assistance/guidance/hints. 1. The problem statement, all variables and given/known data: How do I write a shell script that takes in a file or... (4 Replies)
Discussion started by: fozilla
4 Replies

2. UNIX for Dummies Questions & Answers

Shell input to remove every second file in a directory

Hey guys, I am looking for simple shell script, so i can remove every second file in a directory. For example in any given directory there are 10.000 files: 0001.jpg 0002.jpg 0003.jpg 0004.jpg 0005.jpg 0006.jpg 0007.jpg 0008.jpg .... 1111.jpg 1112.jpg etc. After running the... (5 Replies)
Discussion started by: alpha_mouse
5 Replies

3. Shell Programming and Scripting

find and replace in a directory using an input file

Hi folks, I need help to finish this script please. see below: I have an input file with all the IP address to names formated like so in a txt file addnsr1pri 166.7.3.105 addnsr1sec 166.2.100.22 addnsr2pri 166.2.220.121 addnsr2sec 166.3.68.45... (12 Replies)
Discussion started by: richsark
12 Replies

4. Shell Programming and Scripting

comparing users input to a file in another directory?

how would i go about comparing a users input to a file which is in another directory? (2 Replies)
Discussion started by: gangsta
2 Replies

5. UNIX for Advanced & Expert Users

Removing all file for the particular directory

i want remove all the files from below directory Available directory foa/commprog/data foa/commprog/a foa/commprog/b mfoa/commprog/data mfoa/commprog/a mfoa/commprog/c dfoa/commprog/d There are more folders like this i want to remove the the file from only /data i need only... (3 Replies)
Discussion started by: kingganesh04
3 Replies

6. Shell Programming and Scripting

How to create a directory structure with getting input from a file.

Hi How to create a directory structure with getting input from a file. I have file in that following lines are written. ./activemq-4.1.2/activemq-core-4.1.2.jar ./activemq-4.1.2/backport-util-concurrent-2.1.jar ./camel-1.4.0/apache-camel-1.4.0.jar ./camel-1.4.0/lib/activation-1.1.jar... (12 Replies)
Discussion started by: itsjoy2u
12 Replies

7. Filesystems, Disks and Memory

Removing a file from a directory

How do you remove a file named '-'? ('rm' does not work) (5 Replies)
Discussion started by: npatel
5 Replies

8. Shell Programming and Scripting

Removing the oldest file in a directory

Hi all, I need your assistance in removing the oldest file in a directory. I posted the same thread 3 days back and I got the following answer ls -1 -t | tail -1 | xargs rm which is not covering the case when there are directories older than the oldest file. So, could you please... (2 Replies)
Discussion started by: pavan_movva
2 Replies

9. Shell Programming and Scripting

input a line at the beginning of every file in a directory?

if need to input a word or anything at the beginning of every file in a directory. how do i accomplish this? say the file is named hyperten. how do i make hyperten the first line of every file in a given directory? thanks (6 Replies)
Discussion started by: Terrible
6 Replies

10. Shell Programming and Scripting

perl question - removing line from input file

In perl I want to do remove the top line of my input file then process the next line. I want to do something like head -1 inputfile > temp grep -v temp inputfile > newinputfile cp newinputfile inputfle is this possible in perl? (3 Replies)
Discussion started by: reggiej
3 Replies
Login or Register to Ask a Question