change the output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting change the output
# 1  
Old 11-28-2007
change the output

I have a applicaton , when run /tmp/my_script , that will output the result to the screen ( as below ) , the output is very long ( about 1500 lines ) , I have a program ( as below ) that will show the output with function 1 > 1 , it works fine , however , the output only show page 1 of this 1500 lines ( round 60 lines output is shown ) , can advise what is wrong , how to output all 1500 lines ? besides , if I want the output only have fisrt two column ( date & time in my case ) , the number column do not show , can advise how to change my program ? thx in advance.



the result
======
04/15/07 01:00:00 1 8 7 8 5 8 4 5 5 7
04/15/07 02:00:00 1 2 58 7 5 6 4 1 8
"
"
"
(total 1500 lines )


My program
=======
#vi /tmp/my_program
#/bin/ksh
/tmp/my_script <<EOF
sleep 1
sleep
1
EOF
# 2  
Old 11-28-2007
Just pipe the output to cut or awk as shown below:

Code:
/tmp/my_script | cut -d " " -f 1,2

or

Code:
/tmp/my_script | awk '{print $1, $2}'

Regards
# 3  
Old 11-28-2007
Quote:
Originally Posted by Franklin52
Just pipe the output to cut or awk as shown below:

Code:
/tmp/my_script | cut -d " " -f 1,2

or

Code:
/tmp/my_script | awk '{print $1, $2}'

Regards


for my first question , why it only show the page 1 , it is because it is wait to press "enter" key to next page , can advise if I want to add the "enter" command to my program , what can i do ? thx

#vi /tmp/my_program
#/bin/ksh
/tmp/my_script <<EOF
sleep 1
1
"enter"
"enter"
sleep 1
1
EOF
# 4  
Old 11-28-2007
Not sure what you're trying to do with the script "/tmp/myprogram".
Besides of that, the shebang (the first line) of your script isn't proper, it should be:
Code:
#!/bin/ksh

Anyway, did you get the right output with the awk or cut command?

Regards
# 5  
Old 11-29-2007
thx reply ,

for my first question , I can get all those 1500 lines but the application need to press "enter" key when I want go to next page ( 1500 lines have many pages ) , so I want to ask how to add the enter to my program , just like some unix key ^M etc.
# 6  
Old 11-29-2007
Not sure if you can use the yes command, but you can try it:

Code:
yes "" | /tmp/my_script | awk '{print $1, $2}'

At the end you can get a "broken pipe" message, but don't worry you can just ignore it.

Regards

Last edited by Franklin52; 11-29-2007 at 04:04 PM.. Reason: adding "" arg for yes command
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Extract name from path and change output

Dear All, I would like to extract the file name without extension form a variable... In particular I have a command like this one: for file in path/to/file/example_number.ext do something -input $file -output ${file%_number.ext}.new done means that in variable $file are saved all the path... (3 Replies)
Discussion started by: giuliangiuseppe
3 Replies

2. Shell Programming and Scripting

awk - Why does output order change?

I have this END section in an awk script: END { for (j in littlebin) { print (j, int(log(j)/log(2)) , littlebin) lbsum+=littlebin } for (i in bins) ... (6 Replies)
Discussion started by: treesloth
6 Replies

3. Shell Programming and Scripting

change output format using ksh

I have a script that reaches out to several systems and pulls back infomation in serveral files. I would like to take the infomation returned and reformat it so I can export it to excel. Below is current output: File1:item1:abc=1 File1:item2:efg File2:item1:ab=1 File2:item2:efg... (3 Replies)
Discussion started by: oldman2
3 Replies

4. Shell Programming and Scripting

find output seems to change when piped

Currently, i am trying to create a simple robust script that is intended to move the contents of a given source directory to a target directory. Optionally, the script should allow to either move the whole source dir content, or dotfiles only, or visible files only. I am aware the target directory... (0 Replies)
Discussion started by: shells_bells
0 Replies

5. Shell Programming and Scripting

How can I change is output format by awk ?

Hello, Can you tell me how can I change this format by awk Input 0.2057422D-01 0.2463722D-01 -0.1068047D-02 Output 0.02057422 0.02463722 -0.001068047 Thanks wan (8 Replies)
Discussion started by: wanchem
8 Replies

6. Shell Programming and Scripting

change the output format

when i run the following command db2 list tablespaces Tablespaces for Current Database Tablespace ID = 0 Name = SYSCATSPACE State = 0x0000 Tablespace ID ... (3 Replies)
Discussion started by: lazydev
3 Replies

7. Emergency UNIX and Linux Support

Read file and change a 0 to a 1 in output

<key>ExcludeSimpleHostnames</key> <integer>0</integer> <key>FTPPassive</key> Need simple command that will change the 0 to a 1 in this file when I grep it, but only for this integer key directly after the ExcludeSimpleHostnames key. I got this output code... (8 Replies)
Discussion started by: glev2005
8 Replies

8. Shell Programming and Scripting

Change output if file is empty

I'm very new to writing scripts, so here is my problem...I have the following code already written (in perl) system "rm file2"; open(FILE2, ">file2"); open(MYINPUTFILE, "file"); while(<MYINPUTFILE>) { my($line) = $_; chomp($line); print file2 "$line\n"; print... (2 Replies)
Discussion started by: ddrew78
2 Replies

9. Shell Programming and Scripting

How to Change Uname output?

I want use fake uname anyone can guide? (9 Replies)
Discussion started by: redstaing
9 Replies

10. Shell Programming and Scripting

How to Change Uname output?

I want replace 2.6.15-25-server with 2.6.17 ? $uname -r 2.6.15-25-server 1) mv /bin/uname /bin/uname.orig 2) put the following in the new /bin/uname: #!/bin/sh echo Uname (New Version) /bin/uname.orig :confused: (3 Replies)
Discussion started by: pop_black
3 Replies
Login or Register to Ask a Question