The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirect output to a file name csecnarf UNIX for Dummies Questions & Answers 7 06-16-2008 03:45 AM
redirect input from file? bjornrud UNIX for Dummies Questions & Answers 1 03-09-2008 02:37 AM
redirect output to log file kalyanraj Shell Programming and Scripting 2 06-07-2007 12:40 AM
redirect output to file xadamz23 Shell Programming and Scripting 4 06-29-2006 11:20 AM
redirect output to file? slackware Shell Programming and Scripting 1 09-12-2003 02:57 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-17-2008
Sandeep_Malik Sandeep_Malik is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 27
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 03:13 AM..
  #2 (permalink)  
Old 09-17-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,391
Quote:
Originally Posted by Sandeep_Malik View Post
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 (permalink)  
Old 09-17-2008
Sandeep_Malik Sandeep_Malik is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 27
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 (permalink)  
Old 09-17-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
try this:
Code:
.
.
outfile=$output"_new.txt"
nawk -f malik.awk $DCDB $LDS $Input > $outfile
  #5 (permalink)  
Old 09-17-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,391
then use
filename=`basename /home2/malik/Input/LIVE9091.S20080817`
redirect it to $output/$filename"_new.txt"
  #6 (permalink)  
Old 09-17-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Code:
nawk -f malik.awk $DCDB $LDS $Input > ${output}_$(basename $Input)_new.txt
  #7 (permalink)  
Old 09-17-2008
Sandeep_Malik Sandeep_Malik is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 27
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0