Friday, July 6, 2018

Shell script for read line from text file

My need:


Read line from the text file by shell script and append few text before and after the line.

Script:

#!/bin/bash
file="/root/scource.txt"
while IFS= read -r line
do
                echo -e "        <User>"
                echo -e "            <Path>$line</Path>"
                echo -e "        </User>"
done <"$file"


cat source.txt

/home/kumar
/home/moulee
/home/admin

Output:
<User>
  <Path>/home/kumar</Path>
</User>
<User>
  <Path>/home/moulee</Path>
</User>
<User>
  <Path>/home/admin </Path>
</User>

No comments:

disable_functions with Easy Apache 4 and PHP-FPM

Recently I've faced the issue about disable_functions !!! I need to use 'shell_exec' for one of application with PHP. By de...