Help me to modify my script in stdout


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help me to modify my script in stdout
# 1  
Old 07-19-2011
Help me to modify my script in stdout

please help me to modify my script
Code:
#! /bin/bash
while read line
do
echo "$line"  >>/tmp/result && mysql  -ss -e "use $line; select count(*) from users where type='admin' and deleted = 0;" > /tmp/result;
done < /tmp/db_data

cat result 

alan_hardwsdefs
2
bgrmods
2
claudiatdsefs
1
derek_dbdmma
3

Is there a way to print the output in same lines

Need a result like this
Code:
alan_hardwsdefs 2
bgrmods 2
claudiatdsefs 1
derek_dbdmma 3


Last edited by Scott; 07-19-2011 at 01:22 PM.. Reason: Please use code tags
# 2  
Old 07-19-2011
You can use echo -n $line

Quote:
DESCRIPTION
-n do not output the trailing newline
# 3  
Old 07-19-2011
thank`s it works!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[BASH] Performance question - Script to STDOUT

Hello Coders Some time ago i was asking about python and bash performances, and i was told i could post the regarding code, and someone would kindly help to make it faster (if possible). If you have noted, i'm on the way to finalize, finish, stable TUI - Text(ual) User Interface. It is a... (6 Replies)
Discussion started by: sea
6 Replies

2. UNIX for Advanced & Expert Users

Init.d script stdout location

I'm looking into a Solaris(S10) startup problem, with a script configured to run in /etc/rc3.d. It's written to output trace information to a logfile using tee, but the file itself is clearly not being updated. Is there a default stdout/stderr location for startup scripts where the other branch of... (6 Replies)
Discussion started by: JerryHone
6 Replies

3. Shell Programming and Scripting

Mkbootfs writing to stdout in bash script

Hi, I need to automate some repacking tasks of a boot image for Android When in command line, I can use this command: mkbootfs /path/to/root > /path/to/ramdisk-recovery.cpio;However, if I try to run the command from a shell script under Ubuntu, it fails and outputs to stdout instead of the... (27 Replies)
Discussion started by: Phil3759
27 Replies

4. Shell Programming and Scripting

STDOUT and STDERR redirection within a script

Hello all, I have a for loop executing in a script that I want to redirect STDOUT to screen and to file, while directing STDERR to the bit bucket. Here is the general sentax of what I'm doing: for i in thingy do some_command ${i} done 1>&1 | tee ${LOGFILE} 2> /dev/null What I am... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

5. UNIX for Dummies Questions & Answers

displaying stdout of a script using vi editor

Hi, Is there a way to display the stdout of a script using vi editor without writing the stdout to a file. I have a script (format.sh) which reads a file and displays it in a special format. i want to see this displayed text using vi editor? currently i am doing: format.sh myfile> out.txt... (1 Reply)
Discussion started by: yakari
1 Replies

6. Shell Programming and Scripting

Cisco TCL script write stdout to tftpboot

I want to log the following stdout: router(config)#scripting tcl init tftp://192.168.1.1/remote-ping.tcl ===================================== tclsh proc rping {} { foreach address { 192.168.1.1 192.168.2.1 } { ping $address re 50 si 1500 } ===================================== ... (0 Replies)
Discussion started by: research3
0 Replies

7. UNIX for Advanced & Expert Users

How to capture STDOut of script in a CGI script?

Hi Perl Experts, I am invoking a shell script thru a perl script and the perl script is cgi script.I need to capture the STDOUT of the shell script in the html page where I am invoking the script .?The shell script takes couple of mintutes to complete its execution .Mean while my html page does... (1 Reply)
Discussion started by: kittu1979
1 Replies

8. Shell Programming and Scripting

Please help to modify my script

Hi, I have a script which connect to ATM's and pull two files from the ATM. The which i try to pull is like PIC20085200001*.JPG First 7 digit consist of year montn and date as well After todays execution i want to change the date to next date I add few lines in the script but it is not... (6 Replies)
Discussion started by: Renjesh
6 Replies

9. Shell Programming and Scripting

Modify Perl script to work with txt - Permissions script

Hi I have this code, and i want work with a ls -shalR output in .txt What i need read to do this?? Where start? #!/usr/bin/perl # Allrights- A perl tool for making backups of file permissions # Copyright (C) 2005 Norbert Klein <norbert@acodedb.com> # This program is free... (1 Reply)
Discussion started by: joangopan
1 Replies

10. Shell Programming and Scripting

Script Output Woes (stdout?)

Hey everyone. I have been trying a few filtering scripts with both SED and PERL. So far I have both of these versions working to reformat the incoming text stream (from stdin) into the corrent format (it looks good in the terminal), but I don't think that I am doing it right because the... (2 Replies)
Discussion started by: c0nn0r
2 Replies
Login or Register to Ask a Question