More redirection testing
This commit is contained in:
parent
5d78a62a0d
commit
ec6f3c7ec7
8
Misc/appending_output
Normal file
8
Misc/appending_output
Normal file
@ -0,0 +1,8 @@
|
||||
Everytime this script run this should be added to file
|
||||
This could be useful for logfiles and such
|
||||
Everytime this script run this should be added to file
|
||||
This could be useful for logfiles and such
|
||||
Everytime this script run this should be added to file
|
||||
This could be useful for logfiles and such
|
||||
Everytime this script run this should be added to file
|
||||
This could be useful for logfiles and such
|
16
Misc/appending_redirections.sh
Executable file
16
Misc/appending_redirections.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Jack-Benny Persson
|
||||
# LX13
|
||||
# Testing out permanent appending redirections
|
||||
|
||||
exec 1>>appending_output
|
||||
|
||||
echo "Everytime this script run this should be added to file"
|
||||
echo "This could be useful for logfiles and such"
|
||||
|
||||
# Closing it again
|
||||
exec 1>&-
|
||||
echo "We won't be able to print this line since we no longer have STDOUT"
|
||||
|
||||
exit 0
|
1
Misc/infile.txt
Normal file
1
Misc/infile.txt
Normal file
@ -0,0 +1 @@
|
||||
Hellooo!
|
@ -6,11 +6,21 @@
|
||||
|
||||
exec 3>&1
|
||||
exec 1>reset_test
|
||||
|
||||
echo "This line should go to the reset_test file"
|
||||
|
||||
exec 1>&3
|
||||
|
||||
echo "And this should be outputted on STDOUD as normal"
|
||||
|
||||
|
||||
# And one can also redirect input and then reset it the same was
|
||||
# as with output above
|
||||
exec 5<&0
|
||||
exec 0<infile.txt
|
||||
cat
|
||||
|
||||
exec 0>&5
|
||||
read Yay
|
||||
echo $Yay
|
||||
|
||||
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user