Inserting ouput into a file using redirection


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Inserting ouput into a file using redirection
# 1  
Old 09-25-2014
Inserting ouput into a file using redirection

Hallo Team,

I would like to redirect an output from a file into another file. Here are the two commands/files.

Code:
-bash-3.2$ cat lack.csv
lemontwistpax
-bash-3.2$ ll -ltr BW*|tail -1
-rw-r--r-- 1 mind mind   1844 Sep 25 12:06 BW-CDR-20140925111000-2-AC162DB137C8-164345-000.csv_rejected_6032856-20140925120544.log
-bash-3.2$ ll -ltr BW*|tail -1 << cat lack.csv
>
>

i would like to append the output from lack.csv into whatever
file would appear when i run
Code:
ll -ltr BW*|tail -1

# 2  
Old 09-25-2014
your command >> your_output_file

Read more from here I/O Redirection
# 3  
Old 09-25-2014
Akshay thank you but its not working:
Code:
-bash-3.2$ ll -ltr BW*|tail -1 >> cat lack.csv
-bash-3.2$ grep -l lemontwistpax BW*2014*
-bash-3.2$ cat lack.csv
lemontwistpax
-bash-3.2$ grep lemontwistpax BW*2014*
-bash-3.2$ cat lack.csv >> ll -ltr BW*|tail -1
cat: invalid option -- l
Try `cat --help' for more information.
-bash-3.2$

# 4  
Old 09-25-2014
Quote:
Originally Posted by kekanap
Akshay thank you but its not working:
Code:
-bash-3.2$ ll -ltr BW*|tail -1 >> cat lack.csv
-bash-3.2$ grep -l lemontwistpax BW*2014*
-bash-3.2$ cat lack.csv
lemontwistpax
-bash-3.2$ grep lemontwistpax BW*2014*
-bash-3.2$ cat lack.csv >> ll -ltr BW*|tail -1
cat: invalid option -- l
Try `cat --help' for more information.
-bash-3.2$

This is invalid syntax
# 5  
Old 09-25-2014
Quote:
Originally Posted by kekanap
Hallo Team,

I would like to redirect an output from a file into another file. Here are the two commands/files.

Code:
-bash-3.2$ cat lack.csv
lemontwistpax
-bash-3.2$ ll -ltr BW*|tail -1
-rw-r--r-- 1 mind mind   1844 Sep 25 12:06 BW-CDR-20140925111000-2-AC162DB137C8-164345-000.csv_rejected_6032856-20140925120544.log
-bash-3.2$ ll -ltr BW*|tail -1 << cat lack.csv
>
>

i would like to append the output from lack.csv into whatever
file would appear when i run
Code:
ll -ltr BW*|tail -1

Hello kekanap,

Could you please try following, it is not tested so please test it on a test file first please.

Code:
cat lack.csv >> `ls -ltr BW*|tail -1`

Thanks,
R. Singh
# 6  
Old 09-25-2014
R.Signgh ...... no luck my friend

Code:
-bash-3.2$ cat lack.csv >> `ls -ltr BW*|tail -1`
-bash: `ls -ltr BW*|tail -1`: ambiguous redirect
-bash-3.2$

# 7  
Old 09-25-2014
Quote:
Originally Posted by kekanap
R.Signgh ...... no luck my friend

Code:
-bash-3.2$ cat lack.csv >> `ls -ltr BW*|tail -1`
-bash: `ls -ltr BW*|tail -1`: ambiguous redirect
-bash-3.2$

Hello kekanap,

Could you please try following. This works for me.

Code:
cat lack.csv >> $(ls -ltr BW* | awk 'END{print $9}')

Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inserting IDs from a text file into a sequence alignment file

Hi, I have one file with one column and several hundred entries File1: NA1 NA2 NA3And now I need to run a command within a mapping aligner tool to insert these sample names into a sequence alignment file (SAM) such that they look like this @RG ID:Library1 SM:NA1 PL:Illumina ... (7 Replies)
Discussion started by: nans
7 Replies

2. UNIX for Dummies Questions & Answers

Wget ouput to log file

Hi all The following code will update the Dynamic DNS server at Namecheap.com. wget -O 'https://dynamicdns.park-your-domain.com/update?host=www&domain=example.com&password=your DDNS password'Would like to append the output to a log file using >> /path/path/logfile at the end of the command. ... (7 Replies)
Discussion started by: CRChamberlain
7 Replies

3. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

4. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

5. Solaris

LS redirection to a file in same folder

Hello, I need an input from you all. I want to redirect the output of 'ls' command to a file but the file should not display the output file name in it. scenario: ------------ $pwd /home/user1 $ls file1 file2 $ls > file3 $cat file3 file1 file2 file3 In this i dont wish... (6 Replies)
Discussion started by: aravindan
6 Replies

6. Shell Programming and Scripting

View ouput as a file

Hi all , I have a view in teradata , the ouput of that view have to be stored as a file with delimitere as '|'.Is there any possibility of doing this in unix ? Thanks in advance , Vinoth (6 Replies)
Discussion started by: vino.paal
6 Replies

7. Shell Programming and Scripting

Limit ouput file on a shell script

I have this one::) doing jstack on JVM proccess. #!/bin/ksh # ---------------------------------------------------- # capture_jstack.sh <INTERVAL> <COUNT> # run jstack and capture output to a log file #----------------------------------------------------- # # scripts and logs are stored... (3 Replies)
Discussion started by: pointer
3 Replies

8. Shell Programming and Scripting

gawk help for inserting a field of a .txt file in the same file

i had the following type of data file vchrdump: Vouchers For Date :05/01/2009 * ... (4 Replies)
Discussion started by: KANNI786
4 Replies

9. Shell Programming and Scripting

file redirection problem

my querry is suppose i have duplicate std i/p with FD-3 --exec 0<&3 now redirected std i/p to a file ----exec 0<file1 suppose i am reading the file line by line --while read LINE cutting some fields and comparing it with a variable and if a match is found ... (0 Replies)
Discussion started by: mobydick
0 Replies

10. UNIX for Dummies Questions & Answers

File redirection

Is it possible to sh a command and receive the standard output on the scrren and use file redirection ie ls -lt > test. Also On SCO-UNIX there was a tellme command which displayed a message when a script had finished running is there something similar for HP UNIX as it is not working. (4 Replies)
Discussion started by: namtab
4 Replies
Login or Register to Ask a Question