Read a file dynamically


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Read a file dynamically
# 1  
Old 07-04-2011
Read a file dynamically

Hi
my requriment is read the file name dynamically my code is
Code:
#!/bin/sh
file="/c/work/loan/"
Header_Trailer_move()
{

sed '1d;$d' $file| cat >sam.txt
}
Header_Trailer_move

in above given path my list of files or there i have to read file dyanamically when i entered particular file name above code not working

Moderator's Comments:
Mod Comment Please start using [CODE] tags when posting source code, console output, ...


---------- Post updated at 04:32 AM ---------- Previous update was at 01:20 AM ----------

sorry u sent not working in unix how to do it
# 2  
Old 07-04-2011
Code:
#!/bin/sh

MYPATH="/c/work/loan"

rmHeadTail()
{
     sed '1d;$d' $1 > ${1}.new
}

for F in $MYPATH/*; do
     rmHeadTail $F
done

exit 0

# 3  
Old 07-04-2011
If you want to read a file while running the script then..
Code:
#!/bin/sh 
# Save script as scriptname.sh 
# Run as: scriptname.sh my_file.txt
file="/c/work/loan/$1" 
Header_Trailer_move() 
{  
sed '1d;$d' $file >sam.txt 
} 
Header_Trailer_move

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamically split file

Hi guys, I have a file with 10000 entries (there are 2 columns. the first column contains the the product name and the second column contains the quantity of each product). I would like to split this file into 5 different files. I want the 1st entry to go to the fileA the 2nd entry to fileB... (3 Replies)
Discussion started by: coweb
3 Replies

2. Shell Programming and Scripting

Split file Dynamically

Hello , I have a flat file ( comma separated ) and want to split dynamically . If I provide input 3 then rows 1,4,7 will o/p to a file and rows 2,5,8 will redirect to 2nd file and 3,6,9 rows will go to 3rd file So 3 files will be generated . Could it be possible in Unix? (2 Replies)
Discussion started by: Pratik4891
2 Replies

3. Shell Programming and Scripting

Dynamically creating file names from portions of another file name

Not sure how to do the following, but any help would be appreciated. Has to be done using C shell (sorry about that). I have about 300 files that I need this done for, but I am only going to give one example. I will just need to know how to execute your solution through some type of loop to get... (2 Replies)
Discussion started by: jclanc8
2 Replies

4. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

5. Shell Programming and Scripting

How to read a dynamically changing file

I want to read a constantly changing file and do some operation on text found in that file. Actually that is log file of linux system and whenever i find a matching string in that file i want to create a text file with timestamp. is it possible to read that file? here is sample output of log... (7 Replies)
Discussion started by: kashif.live
7 Replies

6. Shell Programming and Scripting

Dynamically locating a file

Hi, I have a requriement where in I need to install a s/w by executing the installable file through a script. The script currently contains the path of the installable file. I need to now update the script accordingly such tht it identifies the location of the installable file automatically and... (1 Reply)
Discussion started by: yoursdavinder
1 Replies

7. UNIX for Dummies Questions & Answers

How can i read array elements dynamically in bash?

Hi friends how can we read array elements dynamically in bash shell? (1 Reply)
Discussion started by: haisubbu
1 Replies

8. Shell Programming and Scripting

How to read a dynamically changing file and load into Oracle?

I have a tab delimited file which has 27 character fields. The file needs to be loaded into an Oracle table. But the challenge is that everytime the file comes it may or may not have values in all 27 fields. Column Definition of the 27 fields: TYPE: Char (1) NAME: Char (30) CUSTOM_VAL: Char... (8 Replies)
Discussion started by: madhunk
8 Replies

9. UNIX for Advanced & Expert Users

dynamically linked file

Hi friends, i have a dynamically linked file on my solaris system.this is script that runs regularly. How can i read the contents of that ? when i tried to say "vi filename " then it says executable and nothing is seen. Please help. thanks in advance Veera (5 Replies)
Discussion started by: sveera
5 Replies

10. Shell Programming and Scripting

dynamically linked file

Hi friends , how do i view a dynamically linked file in unix ? its there on other system and do i have to ftp it in ASCII format or binary ? and after the ftp how do i view it ? thanks in advance veeras (1 Reply)
Discussion started by: sveera
1 Replies
Login or Register to Ask a Question