$line command problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting $line command problem
# 1  
Old 07-21-2006
$line command problem

Hi all!

I have a problem with line command. The aim is to write each line of stdin into a text file.

For example with this command:

Code:
$find /
/usr/share/zoneinfo/WET
/usr/share/zoneinfo/Zulu
/usr/share/zoneinfo/iso3166.tab
/usr/share/zoneinfo/localtime
/usr/share/zoneinfo/zone.tab
/usr/src
/initrd.img
/vmlinuz

I want to write in a file the always the last line printed to stdin, to real-time follow proces execution.

I tried this:

Code:
$find / | line > stdout.file       (no results, only write the first line and exit)
$find / | tail -f -n 1 > stdout.file       (no results, only write the last line and exit)


Any ideas?
Thank you very much
# 2  
Old 07-21-2006
Can you re state your problem. First you are saying that you want to print each line then you are saying only last line...
# 3  
Old 07-21-2006
Try something like this :

Code:
find / |
while read line
   echo $line > stdout.file
done

The stdout.file will allways contains the last line printed by find on stdout

Jean-Pierre.
# 4  
Old 07-21-2006
Thank you Jean-Pierre, the correct code that works is:

Code:
find / |
while read line ; do
   echo $line > stdout.file
done

Thank you very much!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Problem with SFTP Command line, "@" in username.

Hi Guys Any help is appreciated very much! I'm trying to use SFTP to an external server using the native SFTP Client in RHEL 6 and 7. I've been given a username on the remote SFTP Server of myemail@myorg.com. I can not seem to escape that @ sign no matter what I do. I've tried these... (16 Replies)
Discussion started by: BG_JrAdmin
16 Replies

2. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies

3. Red Hat

Problem in access the internet through command line

Hi Folks, I have installed Centos-6.4 in my VMware. I have enabled the proxy settings in the network and I am able to access the internet through GUI, but unable to browse via the command line. I did the below options as: 1) Added the proxy setting in /etc/environment file.export... (4 Replies)
Discussion started by: gsiva
4 Replies

4. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

5. Shell Programming and Scripting

Delete line with match and previous line quoting/escaping problem

Hi folks, I've list of LDAP records in this format: cat cmmac.export.tmp2 dn: deviceId=0a92746a54tbmd34b05758900131136a506,ou=devices,ou=customer,ou=nl,o=upc cmmac: 00:13:11:36:a5:06 dn: deviceId=0a92746a62pbms4662299650015961cfa23,ou=devices,ou=customer,ou=nl,o=upc cmmac:... (4 Replies)
Discussion started by: tomas.polak
4 Replies

6. UNIX for Dummies Questions & Answers

Problem with command line parameters

hi, This is actually realted to a Abinitio command in a unix script. my code is #!/bin/ksh GRAPH_NAME=$1 shift air sandbox run $GRAPH_NAME $* > file.lst 2>&1 if ]; then echo "Pass" fi when i run this script with this command "script.ksh graph_name parameters" the script... (1 Reply)
Discussion started by: siva1612
1 Replies

7. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

8. Shell Programming and Scripting

problem with KSH script: command line args

Hi I am executing a KSH script by passing command line arguments example: Red Green Dark Red Blue when I am splitting the arguments by using " "(Space) as delimiter But the colour Dark Red is a single parameter. But it is getting splitted in between How to avoid this. Please help Also... (4 Replies)
Discussion started by: hemanth424
4 Replies

9. Shell Programming and Scripting

I need suggestion on problem read a file line by line and do stuff

At first, give my best wish for all MOD and admins here. I"m learning bash shell program just for a month, not too much, not too little, but i must admire that i'm very bad at math and algorithm. :( I want to do this : Read the content of a file line by line and at each line, ask me want to... (3 Replies)
Discussion started by: madi3d8
3 Replies

10. Shell Programming and Scripting

problem with command line

i have a command line that looks like this: my_command -a -b -c -d"foo bar" "./run this" param1 param2 I'm using getopt to pharse parameters -a -b -c -d. after that i would like to execute "./run this" param1 param1 (which is places after --) but I'm loosing quotas around ./run this. How can i... (0 Replies)
Discussion started by: sopel39
0 Replies
Login or Register to Ask a Question