Microsoft
Software
Hardware
Network
Question : Unix Script for Reading text file line by line
OK. I need help in unix scripting.
I have attached a sample file. Here are my queries.
1. Read the text file line by line. So there should be 5 lines to be read
2. Find t.mgmt_sa_code='TRADERA' and capture TRADERA in variable.
3. Save each line in a separate file. For e.g. the first line of the file will be saved with a filename TRADERA.sql. So 5 lines means 5 files should be saved when the program is completed
Please provide the script which can do the above.
I believe it should be simple.
Thanks,
ajexpert
Answer : Unix Script for Reading text file line by line
The above was a ksh script,
below is a bash script
#!/usr/bin/bash
while read line ; do
f=${line#*t.mgmt_sa_code="
'"}
echo $line > ${f%"'";*}.sql
done < sample.txt
Random Solutions
Is there a way to prevent googlebot to see words like "or" as keywords?
how to get trigger content into text file programmatically(using T-SQL)?
SQL Server 2005 Table-Valued Function Problem
Customized Page after Login
os2,ibm dial up tcpip
Automatically run VB script upon entering web page
relaying denied IP name lookup failed
Computer takes 30 minutes to boot; after (I think) an automatic update. I had this problem no another computer a few years ago but I forgot the fix.
Explorer can't find network PC but Remote Desktop/ping can
Temp Files Appearing On my Desktop Like A Rash