Input file redirect in output path and want name as inputfilename_new.txt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Input file redirect in output path and want name as inputfilename_new.txt
# 1  
Old 09-17-2008
Input file redirect in output path and want name as inputfilename_new.txt

not required this time

Last edited by Sandeep_Malik; 10-17-2008 at 04:13 AM..
# 2  
Old 09-17-2008
Quote:
Originally Posted by Sandeep_Malik
Hi
i want to add new_txt in my input filename. please suggest some solution. i have provide my code as:
>cat malik.sh
echo Enter DCDB path:
read DCDB
echo Enter LDS file path:
read LDS
echo Enter Input file path:
read Input
echo Enter Output Path:
read output
nawk -f malik.awk $DCDB $LDS $Input > $output"_new.txt"
>
i am providing information as:

>DCDb path: /home2/malik/DCDB.xml
>LDS path: home2/malik/LDS.xml
>Input file : /home2/malik/Input/LIVE9091.S20080817
>Output path: /home2/

i am getting out under dir >
/home2/_new.txt

instead of this, i want output look like.
/home2/LIVE9091.S20080817_new.txt

in the same directory i run my malik.csh and malik.awk scripts also
plase anyone provide answer
in $output you have /home2/ and next you have "_newtext" so from where can it get LIVE9091.S20080817??
# 3  
Old 09-17-2008
I get LIVE9091.S20080817 file from

>Input file : /home2/malik/Input/LIVE9091.S20080817
> output path: /home2/

now i want this input file will redirect in output path as : LIVE9091.S20080817_new.txt

please provide some solution
# 4  
Old 09-17-2008
try this:
Code:
.
.
outfile=$output"_new.txt"
nawk -f malik.awk $DCDB $LDS $Input > $outfile

# 5  
Old 09-17-2008
then use
filename=`basename /home2/malik/Input/LIVE9091.S20080817`
redirect it to $output/$filename"_new.txt"
# 6  
Old 09-17-2008
Code:
nawk -f malik.awk $DCDB $LDS $Input > ${output}_$(basename $Input)_new.txt

# 7  
Old 09-17-2008
thanks a lot for prompt reply
working code is as:

output=./`basename $input`_new.txt
nawk -f malik.awk $DCDB $LDS $input > $output

output is ---LIVE9091.S20080817_new.txt
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search last column of INPUT.txt in TABLEs text and add correspond columns to INPUT.txt

Hi dears i use bash shell i have INPUT.txt like this number of columns different in one some row have 12 , some 11 columns see last column INPUT.txt CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic 63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies

2. UNIX for Dummies Questions & Answers

Redirect output to the same input file in awk

Hi, I want to compare a value from test file and redirect the o/p value to the same file input file 250 32000 32 128 Below is my code awk '{ if ($1 < "300") print $1 > /tmp/test}' test want to compare 250 < 300 then print 300 to the same place below is the... (24 Replies)
Discussion started by: stew
24 Replies

3. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

4. Shell Programming and Scripting

Read file from input and redirect to output file

Hi , i am having an file which contains 5 file_name data, i need to read the file name and will perform certain operation and generate out file names with named as 5 individual file_names for eg: file.txt contains file_name1.txt|hai file_name2.txt|bye file_name3.txt|how... (3 Replies)
Discussion started by: rohit_shinez
3 Replies

5. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

6. UNIX for Advanced & Expert Users

Complex Input/Output Redirect

Hi All, Sorry if the title is not good but I did not know how to explain with only some words! What I meant is: I have a unix command built from a private application vendor that when executed it prompts for two entries by the keyboard, let's say, for example: ... (1 Reply)
Discussion started by: felipe.vinturin
1 Replies

7. Shell Programming and Scripting

redirect an awk string output to a script input with pipes

Hi, I have a function in a bash script that returns a string after some operations using awk. The following code returns 555 $VARIABLE="EXAMPLE" get_number $VARIABLE this value I'd like to pass it as a second argument of another script with the following usage myscript.sh <param1>... (7 Replies)
Discussion started by: rid
7 Replies

8. Programming

Redirect input and output to a shell script?

Dear All: I am trying to do something that (I thought) was relatively straightforward, but my code snippet does not seem to work. Any suggestions? Thank you Sincerely yours Misha Koshelev #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include... (0 Replies)
Discussion started by: misha680
0 Replies

9. UNIX for Dummies Questions & Answers

redirect input from file?

I need to run a command inside root-environment, and want to use: su - root -c "some command..." Then I am prompted for a password, of course. Is it possible to put this password in a file, and present this files content, to the command above?:confused: (1 Reply)
Discussion started by: bjornrud
1 Replies

10. UNIX for Dummies Questions & Answers

How to redirect date with string command into txt file

Hello im trying to redirect the standard output into txt file but with combination of string if I do : date >! foo.txt there is no problem and im getting the date into the foo.txt but what should I do if I like to add string in the same command so the result will be in the txt : The date... (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question