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>
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:
Post a Comment