0
votes
1answer
28 views

Capture Error of LS to file [duplicate]

#!/bin/sh if [ $(ls sample01.log | wc -l) = 1 ] then echo "File Found" > lsOutput.log else echo "File Not Found" > lsOutput.log fi But if sample01.log is not already existing my code already ...
2
votes
2answers
105 views

Is it possible to create a “file” that can be used by any process without actually saving the file on disk?

Suppose I do a grep that gives me a lot of results. I want to use the output of grep and pass it to a command that takes a filename as it's first argument. For example - myCommand filename.txt I ...
2
votes
2answers
95 views

Diverting a file write to process

I have an OSX GUI application which I can't change - it writes new CVS lines to a log file when it completes a job. I'd like to work with these new lines, but they are constantly being added. Is ...
7
votes
1answer
2k views

How to redirect stdout and stderr to a file and display stderr to console?

I know how to redirect to a file, and use tee; on a basic level. So $ alias outanderr='bash -c "echo stdout >&1; echo stderr >&2"' \ # A fake "application" displaying both output and ...
1
vote
1answer
101 views

Standard I/O File Descriptors

I am new to Shell SCripting I code this $ ls -l 1> stdout.txt and I get the output as desired, 1> stdout.txt redirects the output from standard output to the file stdout.txt. I don't ...
0
votes
2answers
412 views

Redirecting stdin with stdout to file

So I have a program that takes in user input and outputs text based on the input. EDIT2: I want to create a script that runs a C executable and the script feeds the C program input from a file and ...
1
vote
1answer
84 views

Unsure about the behaviour of my script when writing to log file

I have a very simple ksh script and at certain points I want to write to a log file. I use the following commands in two places... print "Directory listing 1:\n" > ${LogFile} ll >> ...
3
votes
2answers
697 views

How can i redirect the output to a file when the program is build with ncurses library [duplicate]

Possible Duplicate: Removing control chars (including console codes / colours) from script output If we redirect output to file in this pattern top >> somefile.txt, we get lot of ...
3
votes
1answer
365 views

Redirecting/grep'ing an existing shell's STDOUT

I run a lot of long running processes (simulations) that print progress to STDOUT. I occasionally forget to redirect to STDOUT to a file I can grep, and it's usually too far along to restart. ...
22
votes
3answers
7k views

Reading lines from a file with bash: for vs. while

I'm trying to read a text file and do something with each line, using a bash script. So, I have a list that looks like this: server1 server2 server3 server4 I thought I could loop over this using ...
9
votes
3answers
1k views

Can I make `cut` change a file in place?

The man page doesn't give me much hope, but I'm hoping it's an undocumented (and/or GNU-specific) feature.