LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-17-2011, 05:45 AM   #1
satin132
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
Write in one line output for file and screen


Hallo,

I would like to ask for help. Is there some way to put in one line text I want to print to file and screen? on screen should appear not everithing, what is in file.

I wrote it like this

PHP Code:
echo "["$(date +%Y%m%d%H%M%S"]:\c" >> file.txt
echo "${1}:\c" tee -a file.txt
echo "${2}>> file.txt 
I have one more question. If I have function, which take e.q 3 param, and I want to call her with e.q. one parameter (e.q 3th one), how should call it?

can I like this?

PHP Code:
F_myFunct "" "" "Hallo" 
Thank you very much for your help
 
Old 10-17-2011, 06:23 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,529

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
Quote:
I would like to ask for help. Is there some way to put in one line text I want to print to file and screen? on screen should appear not everithing, what is in file.
Could you try and explain this another way as I do not see what you are asking based on what you have shown us??

Quote:
I have one more question. If I have function, which take e.q 3 param, and I want to call her with e.q. one parameter (e.q 3th one), how should call it?
You can test the number of parameters with $# and then do the appropriate response based on what you find.
 
Old 10-17-2011, 07:15 AM   #3
satin132
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thnak you for answer for second question.

My first question was, if I can write this:
Code:
echo "["$(date +%Y%m%d%H%M%S"]:\c" >> file.txt 
echo "${1}:\c" | tee -a file.txt 
echo "${2}" >> file.txt
somehow easier, like command on one line and no 3 commands on 3 lines. So if $1 = "Halo" , $2 = "World" the ouput in file should be:

Code:
20110101101010: Hallo: World

and on the screen should be
Code:
Hallo:
I hope I explained it a bit easier. Thank you.
 
Old 10-17-2011, 08:16 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,529

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
I cannot see how this would be possible as you are asking for 3 different tasks to 2 objects, ie. file and stdout.
Obviously you could get it down to 2 lines by doing the whole echo into file and then simply echoing first parameter to stdout.
 
Old 10-17-2011, 08:54 AM   #5
satin132
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Ok, thank you. I didnt know if it is posible at all. Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard script output to screen & -x option output to file BoBeau236 Programming 6 05-10-2011 07:43 AM
Output Redirection - Trying to output to screen and file? helptonewbie Linux - Newbie 7 03-19-2009 07:05 AM
Reading screen output line by line basildon Linux - Newbie 1 09-23-2008 01:33 PM
help with c program to read each line from text file, split line , process and output gkoumantaris Programming 12 07-01-2008 12:38 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration