Filename.txt
Code:
My First Line
My Second Line
::::While Loop:::
Program:
Code:
while read line
do
echo "$line"
done < Filename.txt
output:
Code:
My First Line
My Second Line
Is it possible to use for loop to get the same output.
I want to run a command and save its output and its exit code, in different files.
Here's what i am doing:
cmd.exe /C command 1> %TEMP%\output.log 2> %TEMP%\error.log && echo %ERRORLEVEL% > %TEMP%\status || echo %ERRORLEVEL% > %TEMP%\status
If i don't do output redirection (into %TEMP%\output.log and/or %TEMP%\error.log), then exit code is saved just fine.
However, when i r
Part 1
Say I have a command my_command that outputs multiple lines.
Hi
I have a file which I am reading line by line and processing it.
But the last line is not getting read in the file loop until I put an enter in the end.
Code:
#!/bin/ksh -p
v_org_id=${P1}
FILE=${P2}
NEW_FILE_NAME=$APPLPTMP/b1.txt
BAKIFS=$IFS
IFS=$'\n'
exec 0<"$FILE"
echo "File to be processed.....: ${FILE}"
while read -r line
do
v_initial=`echo "$line&qu
I have a script that outputs text to stdout. I want to see all this output in my terminal, and at the same time I want to filter some lines and save them in a file. Example:
$ myscript
Line A
Line B
Line C
$ myscript | grep -P 'A|C' > out.file
$ cat out.file
Line A
Line C
I want to see output of first command in terminal, and save the output of the second command in a file.
I am trying to read the output of a command in bash using a while loop.
while read -r line
do
echo "$line"
done <<< $(find . -type f)
The output I got
ranveer@ranveer:~/tmp$ bash test.sh
./test.py ./test1.py ./out1 ./test.sh ./out ./out2 ./hello
ranveer@ranveer:~/tmp$
After this I tried
$(find .
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 <
Dear All,
Code:
./waf --run scratch/myfirst > log.out 2>&1
The above is a command line to redirect the output to a file called log.out.
what is the 2>&1 part for ?
Thank you
i have 3 files as below:
Code:
[test1][test2][test3]
i want to print 1st,2nd,5th and 10th filed of 1st to 5th lines from each files into a line of an output file, so the result would be:
[output]:
Code:
{line1}(field 1 of line 1 from file 1)(field 2 of line 1 from file 1)(field 5 of line 1 from file 1)(field 10 of line 1 from file 1)...(field 10 of line 5 from file 1)
{line2}(field 1