Hi Unix gurus,
I have a file. I need to insert sequential number at the starting of the file. Fields are delimited by "|". I know the starting number.
Example:
File is as follows
|123|4test|test
|121|2test|test
|x12|1test|test
|vd123|5test|test
starting number is : 120
... (7 Replies)
Hi i would like to add line numbers to end of each line in a file.
I am able to do it in the front of each line using sed, but not able to add at the end of the file.
Can anyone suggest
The following code adds line number to start of each line
sed = filename | sed 'N;s/\n/\t/'
how can i... (5 Replies)
Hi! I'm trying to assign line numbers to each line of the file
for example consider the following..
The contents of the input file are
hello how are you?
I'm fine.
How about you?
I'm trying to get the following output..
1 hello how are you?
2 I'm fine.
3 How about you? ... (8 Replies)
Hi,
For my reuirement, I have to read a file from the 2nd line till the last line<EOF>.
Say,
I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines.
for i in `cat test.txt`
{
echo $i
}
While doing the above loop, I have read... (5 Replies)
Hello All,
Could you please help with this.
This is what I have:
506234.222 2
506234.222 2
506234.222 2
506234.222 2
508212.200 2
508212.200 2
333456.111 2
333456.111 2
333456.111 2
333456.111 2
But this is what I want:
506234.222 1
506234.222 2
506234.222 2
506234.222 3 (5 Replies)
Hi,
I want to read a live log file line by line and considering those line which start from time stamp;
Below code I am using, which read line but throws an exception when comparing line that does not contain error code
tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
I need to replace the (*) in the fist of a list with numbers using sed for example >
this file contain a list
* linux
* computers
* labs
* questions
to >>>>
this file contain a list
1. linux
2. computers
3. labs
4. questions (7 Replies)
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
LEARN ABOUT CENTOS
while
while(n) Tcl Built-In Commands while(n)
__________________________________________________________________________________________________________________________________________________NAME
while - Execute script repeatedly as long as a condition is met
SYNOPSIS
while test body
_________________________________________________________________DESCRIPTION
The while command evaluates test as an expression (in the same way that expr evaluates its argument). The value of the expression must a
proper boolean value; if it is a true value then body is executed by passing it to the Tcl interpreter. Once body has been executed then
test is evaluated again, and the process repeats until eventually test evaluates to a false boolean value. Continue commands may be exe-
cuted inside body to terminate the current iteration of the loop, and break commands may be executed inside body to cause immediate termi-
nation of the while command. The while command always returns an empty string.
Note: test should almost always be enclosed in braces. If not, variable substitutions will be made before the while command starts execut-
ing, which means that variable changes made by the loop body will not be considered in the expression. This is likely to result in an
infinite loop. If test is enclosed in braces, variable substitutions are delayed until the expression is evaluated (before each loop iter-
ation), so changes in the variables will be visible. For an example, try the following script with and without the braces around $x<10:
set x 0
while {$x<10} {
puts "x is $x"
incr x
}
EXAMPLE
Read lines from a channel until we get to the end of the stream, and print them out with a line-number prepended:
set lineCount 0
while {[gets $chan line] >= 0} {
puts "[incr lineCount]: $line"
}
SEE ALSO
break(n), continue(n), for(n), foreach(n)
KEYWORDS
boolean value, loop, test, while
Tcl while(n)