Read the file line by line and do something with lines
I have a file
The file can have different number of other files names or nothing
I will check
Now I have to start checking file names, i.e. read txt file line by line. If amount of ,lines equal 1, I can do it
Otherwise I think I have to put it in for loop
How can I do it? while (1) is not working.
I don't know if ksh support for loop
The last loop doesn't support KSH.
Better is the following:
Thanks for contribution
Hi digioleg54,
I have no idea what you mean by "The last loop doesn't support KSH." Any POSIX shell and any shell based on Bourne shell syntax does support the while loop MadeInGermany suggested:
And, it is much more efficient and more likely to work than the loop you suggested above. Your has to start up another shell for the command substitution, run the cat utility to get the contents of file_name_0.txt, and will not work correctly if any filename contained in file_name_0.txt contains any IFS characters (by default, including <space> and <tab>). The code MadeInGermany works correctly in this case while your code does not.
While it is true that the code MadeInGermany suggested will not with if you are using csh or one of its derivatives, the code you suggested will not work with those shells either.
Hi all,
I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like:
<date1>|<data1>|<url1>|<result1>
<date2>|<data2>|<url2>|<result2>
<date3>|<data3>|<url3>|<result3>
<date4>|<data4>|<url4>|<result4>
What I... (3 Replies)
Hello,
I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be:
SRVXPAPI001 ERRO JUN24 07:28:34 1775
REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F
... (8 Replies)
I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.
example input line:
... (1 Reply)
I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.
example input line:
... (2 Replies)
Hi,
i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here)
i need to read this file line by line and generate an output file like the one below
i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
I am using the while-loop to read a file.
The file has lines with null-terminated strings (words, actually.)
What I have by that reading - just a first word up to '\0'!
I need to have whole string up to 'new line' - (LF, 10#10, 16#A)
What I am doing wrong?
#make file 'grb' with... (6 Replies)
I need help.....I have number of data files and I need to read the contains of each file which is three lines by awk commands or script, and send each line within the data file to different new file . That means I will have three files as a result, the first file will contains the first lines for... (4 Replies)
STEP 1
# Set variable
FILE=/tmp/mainfile
SEARCHFILE =/tmp/searchfile
# THIS IS THE MAIN FILE.
cat /tmp/mainfile
Interface Ethernet0/0 "outside", is up, line protocol is up
Hardware is i82546GB rev03, BW 100 Mbps
Full-Duplex(Full-duplex), 100 Mbps(100 Mbps)
MAC address... (6 Replies)