Dear Friends ,
Following script is very much helpful for splitting a file contents .....
If any comments ....pls correct as per your knowledge ..
This script is used for the file which content are as follow . You can modify this script as per your application and file structure .
Note Red color indicate modification
suppose your file have the following structure and you want to splitting each line and words of lines then following script is helpful
#cat databasefile.txt
A1005184|361371|24|462132||2002-09-27 02:38:53+00|csym|20020927
A1005183|361371|24|574452||2002-09-27 02:40:27+00|mp3|20020927
A1005184|361371|24|462132||2002-09-27 02:40:27+00|mp3|20020927
A1032533|211189|24|889785|223|2004-05-24 21:34:31+00|ips|20040524
A1032532|363029|24|454995|120|2004-05-24 21:34:28+00|mp3|20040524
Code:
vi file_content_split.sh
1 path="
Code:
/path_of_databasefile.txt"
2
3 echo "Original file "
4 cat $path
5 echo "***************************************"
6
7 for text_file in $path
8 do
9 cat $path | tr "|" "*" > tmp #(translate pipe[|] into *)
10 done
11
12
13 echo "#####################################"
14 echo "Translated File ---------------------"
15 cat tmp
16 echo "------------------------------------"
17 tmp_file="/home/kalinga/sbin/tmp"
18
19 IFS=*
20 while read read_vfile_id read_cust_id read_priority_tat read_vfile_size read_rec_duration read_dt _created read_ext read_datefolder
21
22 do
23 echo "***********"
24 echo "read_vfile_id:" ${read_vfile_id}
25 echo "read_cust_id:"${read_cust_id}
26 echo "read_priority_tat :"${read_priority_tat}
27 echo "read_vfile_size:" ${read_vfile_size}
28 echo "read_rec_duration:" ${read_rec_duration}
29 echo "read_dt_created:"${read_dt_created}
30 echo "read_ext:"${read_ext}
31 echo "read_datefolder:"${read_datefolder}
32 done < $tmp_file > anil.txt
33 echo "Do one thing....... Do it Well ! ---------- Linus Torwald"
34 cat anil.txt
Anil V. Rathod
Linux System Administrator
Kalinga Data Link Pvt.Ltd. Pune
Cell No. 9860062917