awk and save result on a different file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk and save result on a different file
# 1  
Old 05-09-2011
awk and save result on a different file

Hi,
If I type:

ls -l *txt awk '{print $8}'

I get the file listing if I am in the directory.

If I try to do the same from a job flow, doing also other things, I can't do

ls -l directory/*txt awk '{print $8}' > directory/result.txt
or
echo ls -l directory/*txt awk '{print $8}' > directory/result.txt

The error I get is:

line 25: unexpected end of file

SmilieSmilieSmilie

I tried to put " or ' from the beginning but nothing.
# 2  
Old 05-09-2011
Are the number of files in the directory too many?
# 3  
Old 05-09-2011
I am testing with a directory with 8 files only in total.
# 4  
Old 05-09-2011
These commands are working fine. Is it part of a script or just the commands you have executed on the prompt ?
# 5  
Old 05-09-2011
Paste some code snippet. what is line 25 here?
# 6  
Old 05-09-2011
Sorry people, I got it (partially)

At the very top of the flow there was an extra '

now works but I am not happy with the format of the file:

#!/bin/tcsh

##set log = /com/3d/SB11/log_999.txt


echo "ls -l full_path/[5-6]????* awk '{print $8}'" >> $log

nedit $log
Opening the file log_999.txt with nedit I would like to see
file1
filte2
...

But I have
<esc>[00/dir/file1<esc>[00m<esc>[00m/dir/file2<esc>[00m

Last edited by essemario; 05-09-2011 at 04:04 AM..
# 7  
Old 05-09-2011
try this in script
Code:
basename `ls -1 /root/[5-6]????*`

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need to save output of echo and awk to a file

Hi, I am generating a YAML file from a hosts file, but am having trouble saving it to a new file. hosts file 127.0.0.1 localhost 192.168.1.2 host1 192.168.1.3 host2 192.168.1.4 host3 192.168.1.5 host4 YAML file $ echo 'host_entries:' && awk '{printf " %s:\n ip:... (3 Replies)
Discussion started by: sand1234
3 Replies

2. Shell Programming and Scripting

awk parse result that match data from file

i run command that return this result,example : gigabitethernet2/2/4:NotPresent, gigabitethernet2/1/17:UP, gigabitethernet2/1/10:UP, gigabitethernet2/1/5:UP, gigabitethernet2/1/9:UP, gigabitethernet2/1/36:DOWN, gigabitethernet2/1/33:DOWN, gigabitethernet2/1/8:UP,... (19 Replies)
Discussion started by: wanttolearn1
19 Replies

3. Shell Programming and Scripting

awk to parse file and display result based on text

I am trying using awk to open an input file and check a column 2/field $2 and if there is a warning then that is displayed (variantchecker): G not found at position 459, found A instead. The attached Sample1.txt is that file. If in that column/field there is a black space, then the text after... (6 Replies)
Discussion started by: cmccabe
6 Replies

4. Shell Programming and Scripting

awk : split file and rename and save in path according to content

Hello, I'm using Windows 7 ; sed, awk and gnuwin32 are installed. I have a big text file I need to manipulate. In short, I will have to split it in thousands of short files, then rename and save in a folder which name is based upon filename. Here is a snippet of my big input.txt file (this... (4 Replies)
Discussion started by: sellig
4 Replies

5. UNIX for Dummies Questions & Answers

I save the result in a variable

I have friends that this command worked perfectly, but I would like to save the result in a variable, which I have not achieved var=prueba.txt echo $var | cut -d "." -f 1 prueba I need to do this but does not work me salida=echo $var | cut -d "." -f 1 echo "result:$salida" ... (8 Replies)
Discussion started by: tricampeon81
8 Replies

6. Shell Programming and Scripting

Save result to a text file

Currently I have a perl code to combine two different files. #! /usr/bin/perl -w use strict; open FP1,"A.txt"; open FP2,"B.txt"; my ($l1,$l2); while(1) { $l1=<FP1>; chomp $l1; $l2=<FP2>; chomp $l2; last unless(defined $l1 or defined $l2); print "$l1 $l2\n"; } close FP2;... (4 Replies)
Discussion started by: Tzeronone
4 Replies

7. Shell Programming and Scripting

Way to save output result of a program into another new file...

Does anybody know any alternative way to save output result of a program into another new file? I got try the command below: program_used input_file > new_output_file program_used input_file >> new_output_file Unfortunately, both the ">" and ">>" is not work at this case to save the output... (6 Replies)
Discussion started by: patrick87
6 Replies

8. Shell Programming and Scripting

"Time" command and save result in a file.txt

Hi, I'am using "time" to check execution time of some script. Is there any possibility to save time command result into a file ? (2 Replies)
Discussion started by: Physix
2 Replies

9. Shell Programming and Scripting

save the HTML result

Hi all, I am displaying my result in HTML format using tables. I want to save the results in file in the same format along with the table only. How do i do that in perl? I have attached the table structure . I want to save like that itself . with regards (2 Replies)
Discussion started by: vanitham
2 Replies

10. Shell Programming and Scripting

Read file from within AWK and save $1 to a variable

Hi I am very new to NAWK programming so this question is probably going to sound really stupid: I have a NAWK script which contains a DO loop. During each loop it runs a FORTRAN program which in turn generates two output files , each one containing 2 integer variables. I would appreciate it... (8 Replies)
Discussion started by: robbiegregg
8 Replies
Login or Register to Ask a Question