I always run my shell with a command:
./shellName file1 file2
So, in the shell, I can refer file1 as $1 and file2 as $2. However, if I want to run the shell with this command
./shellName < file1 > file2
I tried to read the file1 as standard input and file 2 as standard output. How can I refer file1 and file2 in the shell script? Can I still use $1 and $2?
Thanks in advance.
After a bit of pondering I came up with two solutions: the stat command and using information from the proc file system.
I am trying to start a PowerShell script where the script is written to PowerShell.exe via standard input, for example:
echo Write-Host hello | powershell.exe -Command -
-Command - instructs powershell to use the standard input as the source of the script to execute.
Could some one tell me a single line command to feed my cmd input from a file and delete the same file while the command is still running?
EDIT: By single line command I meant, performing this entire action in one command. This behavior has got to do with executing processes and commands simultaneously.
For class I need to write a Bash script that will take the output from ispell and when I try and request user input inside the while loop it just saves the next line of the file as the user input.
How could I go about requesting user input in the while loop?
#!/bin/bash
#Returns the misspelled words
#ispell -l < file
#define vars
ISPELL_OUTPUT_FILE="output.tmp";
INPUT_FILE=$1
ispell -l <
read something about read here!
Synopsis
read [-ers] [-u ] [-t ] [-p ] [-a ] [-n ] [-d ] [-i ] []
Description
The read builtin reads one line of data (text, user input, ...) from standard input or a supplied filedescriptor number into one or more variables named by .
read something about read here!
Synopsis
read [-ers] [-u fd] [-t timeout] [-p ] [-a ] [-n ] [-d ] [-i ] []
Description
The read builtin reads one line of data (text, user input, ...) from standard input or a supplied filedescriptor number into one or more variables named by .
If I use the bash shell cli and run some program which doesn't return immediately, then I input some letters (basically typing the next command before noticing the previous didn't finish) and the input always looks something like this (especially when using arrow up and down keys:)
]]A^ or ]]B^
And I wonder, is this kind of premature input 'harmful' in anyway, or what does the returned string m
read something about read here!
Synopsis
read [-ers] [-u ] [-t ] [-p ] [-a ] [-n ] [-d ] [-i ] []
Description
The read builtin reads one line of data (text, user input, ...) from standard input or a supplied filedescriptor number into one or more variables named by .