Sponsored Content
Top Forums Shell Programming and Scripting To add a number at the end of the line Post 302355298 by protocomm on Tuesday 22nd of September 2009 09:28:52 AM
Old 09-22-2009
Try this...

Code:
awk -v OFS="" '{print $1,".0/8"}' file



---------- Post updated at 05:28 AM ---------- Previous update was at 05:17 AM ----------

And for the IP double...

Code:
awk  '{gsub("[.]{2}",".",$0)}1' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Select matches between line number and end of file?

Hi Guys/Gals, I have a log file that is updated once every few seconds and I am looking for a way to speed up one of my scripts. Basically what I am trying to do is grep through a text file from start to finish once. Then each subsequent grep starts at the last line of the previous grep to... (4 Replies)
Discussion started by: Jerrad
4 Replies

2. Shell Programming and Scripting

Add a new end of line

Hi, Does anyone know if its possible to add something like an end of line like c or java in unix? dirs=/home/nosnam var='' for dir in $dirs do listDirs=`ls -d1 $dir/*` for eachList in $listDirs do listRepos=`du -ks $eachList | awk '{ x+=$1 }; END { print x... (4 Replies)
Discussion started by: nosnam
4 Replies

3. Shell Programming and Scripting

Number a list at end of line using 'sed'

Hi All I have a script which has produced a list, I have used 'sed' to number my list, but i want to list at end of line with the first line starting at zero (0) and brackets round it ie My List i want Hello (0) this (1) day (2) can (3) be (4) sed '/./=' filename | sed '/./N; s/\n/) /'... (5 Replies)
Discussion started by: chassis
5 Replies

4. UNIX for Advanced & Expert Users

Add line numbers to end of each line

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)
Discussion started by: rudoraj
5 Replies

5. Shell Programming and Scripting

Capturing a number at the end of line and store it as variable

Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it. The text file is in this form text or numbers in first line text or numbers in second line . . . Firsname... (6 Replies)
Discussion started by: amuthiga
6 Replies

6. Shell Programming and Scripting

how to add ; at the end of last line

hi, i have file which is having large sql query eg : i am executing this sql file but now i want to add ; after query on same line i.e. i should look like any idea how to achieve it ? (6 Replies)
Discussion started by: crackthehit007
6 Replies

7. Shell Programming and Scripting

Get the 1st 99 characters and add new line feed at the end of the line

I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed). AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC MY * A02 RESALE 6990788000 Y... (3 Replies)
Discussion started by: udelalv
3 Replies

8. Shell Programming and Scripting

AWK-grep from line number to the end of file

Does anyone know how to use awk to act like grep from a particular line number to the end of file? I am using Solaris 10 and I don't have any GNU products installed. Say I want to print all occurrences of red starting at line 3 to the end of file. EXAMPLE FILE: red green red red... (1 Reply)
Discussion started by: thibodc
1 Replies

9. Shell Programming and Scripting

adding line number to *end* of records in file

Given a file like this: abc def ghi I need to get to somestandardtext abc1 morestandardtext somestandardtext def2 morestandardtext somestandardtext ghi3 morestandardtext Notice that in addition to the standard text there is the line number added in as well. What I conceived is... (4 Replies)
Discussion started by: edstevens
4 Replies

10. Shell Programming and Scripting

Add line at the end

How to add a comma at the end of each line in this file?30 1412 30 3352 30 5254 30 5543 30 7478 3 28 3 30 3 39 3 54 3 108 3 152 3 178 3 182 3 214 3 271 3 286 3 300 3 348 3 349 3 371 (3 Replies)
Discussion started by: gunjan
3 Replies
gets(n) 						       Tcl Built-In Commands							   gets(n)

__________________________________________________________________________________________________________________________________________________

NAME
gets - Read a line from a channel SYNOPSIS
gets channelId ?varName? _________________________________________________________________ DESCRIPTION
This command reads the next line from channelId, returns everything in the line up to (but not including) the end-of-line character(s), and discards the end-of-line character(s). ChannelId must be an identifier for an open channel such as the Tcl standard input channel (stdin), the return value from an invocation of open or socket, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input. If varName is omitted the line is returned as the result of the command. If varName is specified then the line is placed in the variable by that name and the return value is a count of the number of characters returned. If end of file occurs while scanning for an end of line, the command returns whatever input is available up to the end of file. If chan- nelId is in nonblocking mode and there is not a full line of input available, the command returns an empty string and does not consume any input. If varName is specified and an empty string is returned in varName because of end-of-file or because of insufficient data in non- blocking mode, then the return count is -1. Note that if varName is not specified then the end-of-file and no-full-line-available cases can produce the same results as if there were an input line consisting only of the end-of-line character(s). The eof and fblocked commands can be used to distinguish these three cases. EXAMPLE
This example reads a file one line at a time and prints it out with the current line number attached to the start of each line. set chan [open "some.file.txt"] set lineNumber 0 while {[gets $chan line] >= 0} { puts "[incr lineNumber]: $line" } close $chan SEE ALSO
file(n), eof(n), fblocked(n), Tcl_StandardChannels(3) KEYWORDS
blocking, channel, end of file, end of line, line, nonblocking, read Tcl 7.5 gets(n)
All times are GMT -4. The time now is 09:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy