problem with output re director to a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with output re director to a file
# 1  
Old 05-30-2012
problem with output re director to a file

I have a file named XXX_TEF_20120530234576.txt.pgp

I am creating a new file with the below syntax but looks it doesnt like the redirection

Code:
for file in XXX_TEF_20120530234576.txt.pgp ;do;
echo $file
cat $file | /usr/bin/gpg/ -d > echo $file | cut -f1,2 -d'.'
done;

What I want actually is the o.p written to a txt file derived from the file name

basically something like thid

Code:
for file in XXX_TEF_20120530234576.txt.pgp ;do;
echo $file
cat $file | /usr/bin/gpg/ -d > XXX_TEF_20120530234576.txt
done;

can somebody tell me what's wrong with my script?

Last edited by Scrutinizer; 05-31-2012 at 12:42 AM.. Reason: code tags
# 2  
Old 05-30-2012
you can use -o option with gpg command to write into o/p file.
# 3  
Old 05-30-2012
Tks. But i have many files in there and I need to derive it with the cut and echo command for each file o\p
# 4  
Old 05-30-2012
use below code for output file
Code:
$(basename $file ".pgp")

Ex.
Code:
$>basename XXX_TEF_20120530234576.txt.pgp ".pgp"
XXX_TEF_20120530234576.txt

# 5  
Old 05-30-2012
this is truncating the directory path it needs to write to. I don't know where the file is being written to

---------- Post updated at 01:51 PM ---------- Previous update was at 01:40 PM ----------

never mind. Tks for the help. got it working now.
# 6  
Old 05-30-2012
Code:
$>file=/root/XXX_TEF_20120530234576.txt.pgp
$>echo ${file:0:(${#file}-4)}
/root/XXX_TEF_20120530234576.txt

OR
Code:
$>echo $(dirname $file)"/"$(basename $file ".pgp")
/root/XXX_TEF_20120530234576.txt

# 7  
Old 05-30-2012
tks pravin27. I have one quick question.

After I get the decrypted files i need to encrypt them. I need to attach .pgp at the end of the filenames i just derived. How can I do that.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with output file plink GWAS

hi, Can anybody help me about the odd output file yielded by the following command: plink --noweb --allow-no-sex --bfile input_file --assoc --adjust --out output_file In fact, I'd like to perform a simple Bonferroni basic association test, and I obtains the following output file (extract... (1 Reply)
Discussion started by: boro82
1 Replies

2. AIX

Help on System Director

Hi all, the DIRDB on DB2 used by system director was dropped. It's possible to reinstall only the container DIRDB, instead of reinstall all system director software? P.S. If i use "smreset" i have an error: DB21005E An error occurred while accessing the file "db2/temp-connect.sql" I find... (1 Reply)
Discussion started by: Zio Bill
1 Replies

3. AIX

IBM Systems Director

dears is IBM Systems Director free to downlad and install or i must pay to have this application? (2 Replies)
Discussion started by: thecobra151
2 Replies

4. AIX

IBM System Director

Is IBM System Director good for collecting error and notifications from IBM servers such as x3250 x336 etc... or Please give me brief description for the purpose of IBM system Director Thanks in advance (1 Reply)
Discussion started by: Vit0_Corleone
1 Replies

5. Shell Programming and Scripting

problem with print append to output file syntax

I'm trying to output the contents of the infile to the outfile using Append. I will want to use append but the syntax doesn't seem to be working ! Input file (called a.txt) contains this: a a a b b b I'm running shell script (called k.sh) from Unix command-line like this: ./k.sh .... (1 Reply)
Discussion started by: script_op2a
1 Replies

6. Shell Programming and Scripting

problem with suppressed output to file using echo and tee command

Hi, When I run the following command in terminal it works. The string TEST is appended to a file silently. echo TEST | tee -a file.txt &>/dev/null However, when I paste this same line to a file, say shell1.sh, and use bourne shell . I run this file in terminal, ./shell1.sh. However I... (1 Reply)
Discussion started by: shahanali
1 Replies

7. Shell Programming and Scripting

problem parsing output file

Hi Gurus, I am using the following code to parse the output of a file. This code basically parses the file and adds | at the end of each field. But I am getting it wrong in some cases. I have explained it below #----- parse output file, get each field position, ----- #----- and construct... (13 Replies)
Discussion started by: ragha81
13 Replies

8. Shell Programming and Scripting

FTP script for sending a file from one unix directory to another unix server director

Hi, My local server is :/usr/abcd/ Remote server is :/Usr/host/test/ I want to send files from local unix directory(All files starting with O_999) to remote host unix directory. Can any body give me the Unix Shell script to do this. One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies
Login or Register to Ask a Question