File Operation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Operation
# 1  
Old 12-06-2009
File Operation

I have one text file like
1 filename
2 filename2
3 hi
4 myname

i have one variable in which i have index value..i.e.1,2,3 and so...

i want to copy value after the index into somevariable.....

how i can do it....
# 2  
Old 12-06-2009
Code:
var=3
awk -v ln=$var '$1==ln {print $2}'  infile | read somevariable

# 3  
Old 12-06-2009
what is this inline?

is it syntax or i am suppose to write the filename

i want to read the value after index into any variable how i can do it?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

file index operation in loop

i have one file which contains data like the below DE_CODE|AXXANY|APP_NAME|TELCO|LOC|NY DE_CODE|AXXATX|APP_NAME|TELCO|LOC|TX DE_CODE|AXXABT|APP_NAME|TELCO|LOC|BT DE_CODE|AXXANJ|APP_NAME|TELCO|LOC|NJ DE_CODE|AXXANJwt|APP_NAME|TELCO|LOC|WT am going use a for loop or whole loop which will... (3 Replies)
Discussion started by: mail2sant
3 Replies

2. UNIX for Dummies Questions & Answers

Need help in not fetching a file while file writing operation is not completed

Hi All, We have a Unix program in oracle when we run the program this connects to specified ftp and will get the file into local server. We are facing a problem like when file writing operations is not completed, this program is getting the incomplete file. Could anyone please help me... (2 Replies)
Discussion started by: world.apps
2 Replies

3. Shell Programming and Scripting

Program to calculate the operation from file

Hi I have the file has some formulas how to create a program (per, ksh, awk) which calculate the operation and put the result on other file example data of source file - this has separate by ";"... (5 Replies)
Discussion started by: Miguel Gonzalez
5 Replies

4. Shell Programming and Scripting

File Operation when delimiter is (Ctrl+A)

Hi, I am new to Shell Scripting. I need the following help. I have a file which is Ctrl +A delimited.I have to do the following validation 1. Header row second column should be having the SYSdate time stamp.(ddmmyyyyhhmiss) Need compare only sysdate. Time is not required. 2. ln Footer... (2 Replies)
Discussion started by: gatha_vdm
2 Replies

5. Emergency UNIX and Linux Support

Logic for file copy operation

Hi, i need to copy contents from source to destination with a few conditions, Please helpme out. Sample input file $>cat testfile.txt /a/b/c/d | /e/f/g/d (d can be either a file or directory) my conditions are: check if destination is valid and if its a file or directory if its a... (5 Replies)
Discussion started by: raghu_shekar
5 Replies

6. Shell Programming and Scripting

Column operation : cosne and sine operation

I have a txt file with several columns and i want to peform an operation on two columns and output it to a new txt file . file.txt 900.00000 1 1 1 500.00000 500.00000 100000.000 4 4 1.45257346E-07 899.10834 ... (4 Replies)
Discussion started by: shashi792
4 Replies

7. Linux

File read/ write operation

Hi, I am creating a progress bar for file upload for which I have CGI script which copies the data and depending on certain bytes it increments the progress bar. Here, I am writing the incremented value to a file which is read by Ajax at server end. However, here I want to ask that, is it... (18 Replies)
Discussion started by: xs2punit
18 Replies

8. Shell Programming and Scripting

CVS file operation in Perl

Hi All, I have one CVS file, and doing some actions on it. I have removed some columns by SWITCH: { $column eq 'COL1' && do {next;}; $column eq 'COL2' && do {next;}; push(@columns, $column); ... (1 Reply)
Discussion started by: gentleDean
1 Replies

9. UNIX for Dummies Questions & Answers

Simultaneous file read operation

Hi All, I need information on file handling in UNIX enviornment. If in UNIX enviornment I have two process.. P1 P2 Both accessing the same file simultaneosuly(read operation).. Suppose P1 opened the file in read mode first and started reading the file.. Then P2 opens the same file in... (5 Replies)
Discussion started by: chibob
5 Replies

10. Shell Programming and Scripting

line operation in a file

Hello all, I have just started fidling with script. Can anyone please help me out with this question. I have a file that contains the below 4 lines of words Abcd Efgh Ijkl Mnop The question is I want to add a line to the middle of these without using sed or awk. Can anyone bail me out... (4 Replies)
Discussion started by: Musaroro
4 Replies
Login or Register to Ask a Question