how can i write the following statements on one line?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how can i write the following statements on one line?
# 1  
Old 03-15-2006
how can i write the following statements on one line?

Hi,

At the moment, I have the following statements which show like this, but I want it all on one line. How can I do this?

----------------------------
echo "There are"
cat menu | wc -l
echo "characters in the text"
----------------------------

Thanks!
# 2  
Old 03-15-2006
echo "There are $(cat file|wc -l) characters in the text"

Bye
# 3  
Old 03-15-2006
Well I would suggest that you don't do "cat menu | wc -l". Instead use "wc -l < menu". This saves a process. And I don't have the context of this code snippet, so I guess I will assume it is basicly correct despite the fact that "wc -l" is counting lines but you label the output "characters".

So my solution for ksh or bash is:

echo "There are $(wc -l < menu) characters in the text."
# 4  
Old 03-15-2006
try it

echo "There are `cat menu | wc -l ` characters in the text"
# 5  
Old 03-15-2006
thanks for the replies. one last question..how would i search for the amount of 'e' characters in a file? or the amount of any character for that matter.
# 6  
Old 03-15-2006
grep -c "e" file


Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

One Line Command how to use pipe statements to execute and comment on multiple possible outcomes

Hello Forum, I'm looking to expand the following command: INACTIVE_KERNELS=$(python -mplatform | grep -qi red && rpm -qa | grep '^kernel-' |grep -vE `uname -r` | paste -sd \; || echo "Not Red Hat Server") Currently this command will check if my server is RedHat server using the grep -qi... (6 Replies)
Discussion started by: greavette
6 Replies

2. Shell Programming and Scripting

How can I write variables to same line of a file?

I am trying to keep variables in a file. if I have all variables at the same time, I can write them all like below. echo $var1","$var2","$var3 But, these variables are being calculated at different times then they are lost so I want to keep them in a file seperated by "," . echo... (5 Replies)
Discussion started by: snr_silencer
5 Replies

3. UNIX for Dummies Questions & Answers

How to write condition in one line ?

Hello, here is my condition that is working fine, but I would like to know how to write it in one line then Control fi Control is a function that will be read only if the ${file} does not exist. Thanks for your help ; ) (2 Replies)
Discussion started by: Aswex
2 Replies

4. Shell Programming and Scripting

Bash if statements in one line

I have the following bash code, and wondering if it is possible (and a good idea) to write the if statements in one line. # Run raytrac on the sound speed model. if ; then $bashPath/raytrac.bash -fcmd=$fcmd.cmd fi # Plot the travel times and ray paths. if ; then ... (8 Replies)
Discussion started by: kristinu
8 Replies

5. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

6. Shell Programming and Scripting

Write in a file with pipe also in same line

hi, i want to write in a file the output of one command and pile also the same output like ls -lrt > some_file | wc -l (9 Replies)
Discussion started by: narang.mohit
9 Replies

7. Shell Programming and Scripting

how to write next line program

Hi, I am having an input file which contains a group of words,if one specific word comes which goes to next line. example: input file===> shashi country= india comapny= none shashi shashi company= NONE shashi=my name output===> shashi country= india comapny= none shashi shashi... (6 Replies)
Discussion started by: hegdeshashi
6 Replies

8. Shell Programming and Scripting

Re-write first line of a file before printing

Morning All, Quite a simple one this, I hope. What I want to do is to re-write the first line of a file before it's sent to print. The line will be blank initially, and I want to insert some text. The operation can either be done on the file itself (modifying the file on disk), OR in a... (2 Replies)
Discussion started by: alexop
2 Replies

9. Shell Programming and Scripting

How to write multiple echo statements in unix?

How to write multiple echo statements in unix? echo "************************************************************************************************************"; echo This Script do the following functions echo 1. Point 1 echo 2. Point 2 echo 3. Point 3 echo... (2 Replies)
Discussion started by: Shrutiduggal
2 Replies

10. Shell Programming and Scripting

How to place the output of two different echo statements on one line

Hello there, I wrote a shell script to modify the code for some of our clients in our client database. Before starting the data modification the program performs a few checks. When a check is being performed, it should be shown on the screen of the user running the program, the result of... (5 Replies)
Discussion started by: JoBa
5 Replies
Login or Register to Ask a Question