Creating a file from input stream

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating a file from input stream
# 1  
Old 11-05-2013
Creating a file from input stream


Need some help with creating a file from input steam. Meaning from following command myfunc should be able to store the input stream to a file.

echo a b c | myfunc

The file thus created should have -


Here's what I've tried in myfunc() but didn't help -

myfunc() { cat &0 > /tmp/1 }

# 2  
Old 11-05-2013
Probably because that's not valid syntax for a function, or redirection.

myfunc() {
        cat > /tmp/$$

# 3  
Old 11-05-2013
  tr " " "\n" > /tmp/1

# 4  
Old 11-05-2013
Great, thanks guys.
Also I was wondering if there's a way to check if the stream is empty or not?
Currently what I do it check the size of /tmp/$$ after I created it from the steam. Is there a better way of doing it?

Last edited by nexional; 11-06-2013 at 01:30 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

creating separate output file for each input file in python

Experts, Need your help for this. Please support My motive is to create seperate output file for each Input Files(File 1 and File2) in another folder say(/tmp/finaloutput) Input files File 1( a,b,c 43,17104773,3 45,17104234,4 File 2( a,b,c 43,17104773,1... (2 Replies)
Discussion started by: as7951
2 Replies

2. UNIX for Dummies Questions & Answers

Creating a new directory by getting input from user

Hi All, I am really new to Linux.I am trying to write a script for creating a new directory by getting input of folder name from the user.Please help me in this regard. #! /bin/bash echo "Enter name of dir":$filename mkdir -p $filename When executing this I am getting following error ... (13 Replies)
Discussion started by: Pradeep_1990
13 Replies

3. Shell Programming and Scripting

Creating a script requiring a pause for user input

Hi I'm trying to create a basic script that pauses for user input to verify a file name before generating the output. I have numerous SSL certificate files which I am trying to determine the expiry date so what I'm trying to do is write a script so that is pauses to request the name of the .pem... (9 Replies)
Discussion started by: Buddyluv
9 Replies

4. Shell Programming and Scripting

[KSH] Creating automatic variable from read input

Hello there, I am posting to seek help with a KSH script, I am making a simple calculation program where the user can enter as many numbers as they like, I am getting their input using the read command, however I am not sure how to repeat doing this and storing the input in to new variables... (7 Replies)
Discussion started by: pandapowerbox
7 Replies

5. Shell Programming and Scripting

Creating Dynamic Input or daa files

Hi, I got a requirement to automate the process. We have SLA files, there are some 80 SLA files comes from 1.30pm - 5.30pm. I was asked to write a script to check for the SLA files in the load directory, if the files come then we got to send the mail to the group, if the mails doesnt come... (1 Reply)
Discussion started by: afahmed
1 Replies

6. Shell Programming and Scripting

[Video stream] network stream recording with mplayer

Hi I used this command: mplayer http://host/axis-cgi/mjpg/video.cgi -user root -passwd root \ -cache 1024 -fps 25.0 -nosound -vc ffh264 \ -demuxer 3 -dumpstream -dumpfile output.avi It's ok but... Video Playing is very fast! Why? Is it a synch problem? What parameter I have to use for... (1 Reply)
Discussion started by: takeo.kikuta
1 Replies

7. UNIX for Dummies Questions & Answers

Get the last value in the input stream

Hello Everyone, The situation is: $ alias rm="sh" read input echo "The input was: " $input $ rm xyz.txt should return "The input was: xyz.txt" Here, I want the alias "rm" to execute the file "", where "" should take "xyz.txt"... (1 Reply)
Discussion started by: qasim
1 Replies

8. Shell Programming and Scripting

creating files and getting input from another file

I have a file where i have files name with absolute path. Ex: files.dat and contents are: /root/xy/yz/zz/abc.txt /root/xx/yy/zz/ac.txt /root/xz/yz/zx/bc.txt /root/xy/yz/zx/abcd.txt now i want to create all above files(dummy files and can be 0 byte). i thought of using touch but it doesn't... (10 Replies)
Discussion started by: ajayyadavmca
10 Replies

9. Shell Programming and Scripting

creating unique lists from user input

hi all, I'm trying to resolve a scenario where we prompt the user to enter 1 or more disk names. From there we would run a command on each disk which would give its location. This would allow us to create a list of disks at location A, a list of disks at location B,....etc... Any help... (1 Reply)
Discussion started by: annie
1 Replies

10. Programming

File I/O Stream

Hi All, I am trying to read data from two files and then compare them and only print the records on the screen that have a same ID.i.e TAGNO =CUSTOMERNO For Eg My Input Files are (a) Transaction (b) Customer detail The data in file a is like: TagNo Date Time Station... (0 Replies)
Discussion started by: rooh
0 Replies
Login or Register to Ask a Question