Here is a simple interactive shell script to redirect all stdout from the subshell.For example if the user wants to
redirect contents of files entered to the file in temporary folder /tmp/sh, it can be done as follows :
Vim Script_Name.sh
:i
#!bin/bash
echo -n "Enter the file whose content is to be redirected using subshell: "
read file_path
#enter the path of the file whose data is to be redirected.Multiple files can be given.
(
cat $file_path
)>/tmp/sh
#The data is redirected to temporary folder.
:wq
The above script can be executed directly as follows:
# bash Script_Name.sh
OR
# sh Script_Name.sh
The script can also be executed by giving execute permission as follows:
# chmod +x Script_Name
# ./Script_Name
0 comments:
Post a Comment