Monday, December 5, 2011

print text files word by word

ubuntu1004@ubuntu1004:~$ cat file.txt
BEGIN
This is first line.
This is the second line.
This a third line.
END
ubuntu1004@ubuntu1004:~$ read -a file <<<$(cat file.txt)
ubuntu1004@ubuntu1004:~$ echo ${file[@]}
BEGIN This is first line. This is the second line. This a third line. END
ubuntu1004@ubuntu1004:~$ echo ${#file[@]}
15
ubuntu1004@ubuntu1004:~$ echo -n ${file[@]}
BEGIN This is first line. This is the second line. This a third line. END
ubuntu1004@ubuntu1004:~$
ubuntu1004@ubuntu1004:~$ for i in ${file[@]};do echo "$i";done
BEGIN
This
is
first
line.
This
is
the
second
line.
This
a
third
line.
END
ubuntu1004@ubuntu1004:~$ for i in ${file[@]};do echo -n "$i";done
BEGINThisisfirstline.Thisisthesecondline.Thisathirdline.ENDubuntu1004@ubuntu1004:~$ for i in ${file[@]};do echo -n "$i";done
ubuntu1004@ubuntu1004:~$
ubuntu1004@ubuntu1004:~$ for i in ${file[@]};do echo -n "$i ";done
BEGIN This is first line. This is the second line. This a third line. END ubuntu1004@ubuntu1004:~$
ubuntu1004@ubuntu1004:~$
ubuntu1004@ubuntu1004:~$ for i in ${file[@]};do echo -n "$i ";sleep .1;done
BEGIN This is first line. This is the second line. This a third line. END ubuntu1004@ubuntu1004:~$
ubuntu1004@ubuntu1004:~$
ubuntu1004@ubuntu1004:~$ for i in ${file[@]};do echo -n "$i ";sleep .05;done
BEGIN This is first line. This is the second line. This a third line. END ubuntu1004@ubuntu1004:~$

No comments:

Post a Comment