Sponsored Content
Top Forums Shell Programming and Scripting Need to read a file in reverse Post 100764 by Ygor on Wednesday 1st of March 2006 10:45:07 PM
Old 03-01-2006
From "HANDY ONE-LINERS FOR SED" ...
Code:
# reverse order of lines (emulates "tac")
 sed '1!G;h;$!d'               # method 1
 sed -n '1!G;h;$p'             # method 2

 

10 More Discussions You Might Find Interesting

1. IP Networking

reverse lookup file problem

I'm trying to create a reverse lookup file. Below are the error messages I get in the messages file, when I start named. Below the error messages is a copy of the reverse lookup file I'm trying to use. I'm using Bind version 8.1.2. Would someone recommend the correct values and if you see any... (2 Replies)
Discussion started by: Westy564
2 Replies

2. UNIX for Dummies Questions & Answers

Reverse Arrange File

I've got hundreds of lines in a file that looks like this: Line1 CCR CCH Line2 ICVM FBO GSC Line3 MKF The result should be like the one below so that I can insert them on our database. Line1 CCR Line1 CCH Line2 ICVM Line2 FBO Line2 GSC Line3 MKF Thanks in advance! (4 Replies)
Discussion started by: The One
4 Replies

3. Shell Programming and Scripting

How reverse cut or read rows of lines

Hi, My records are like this BSC403_JAIN03|3153_TropicalFarm_LIMJM1-3_97| BSC403_JAIN03|3410_PantaiAceh_PCEHM1_4_97| BSC406_BMIN02|1433_JomHebohTV3_COW7M1_11_97| I want to extract the value before _97| This command BSC_ID=`echo $DATA | cut -f5 -d"_"` gives me _97|, 4, 11 and by... (16 Replies)
Discussion started by: doer
16 Replies

4. UNIX for Advanced & Expert Users

How to reverse the contents of a file?

Hi Guys, Am new to this forum .... And also to shell scripting I need a k-shell script to reverse the contents of a file... Please come up with the solutions... With regards, Anand (10 Replies)
Discussion started by: aajan
10 Replies

5. Shell Programming and Scripting

read line in reverse order from file

dear all i want to read 5th no of line from last line of file. kindly suggest me possible ways. rgds jaydeep (2 Replies)
Discussion started by: jaydeep_sadaria
2 Replies

6. Shell Programming and Scripting

how to reverse file

i am using AIX -ksh how can i reverse any file ,i have already try tac cmd it is not in AIX: please help me out. (3 Replies)
Discussion started by: RahulJoshi
3 Replies

7. Shell Programming and Scripting

reverse sort file

Hi all I am trying to numerically reverse sort a file but I seem to be having trouble. Example of file contents: text1,1 text2,-1 text3,0 I can sort using sort -k 2n -t, filename without any problems. However I want my results in descending order but using -r in my command... (2 Replies)
Discussion started by: pxy2d1
2 Replies

8. Shell Programming and Scripting

searching reverse in a file

HI all, i have a file called monitor.cfg and have some sections,under these sections many parameter's are there. like..... MONITOR.CFG p1 p2 p3 #comments #comments p4 p5 p6 eof. i want to add some new parameters in section exactly at end of comments using sed. Thanks surya (4 Replies)
Discussion started by: suryanarayan
4 Replies

9. UNIX for Dummies Questions & Answers

reverse first field from the file

Hi all, I have a file named file1as 07/25 00:10 d327490 07/25 00:55 d378299 07/25 03:58 d378299 07/25 06:14 d642035 07/25 12:44 c997126 and now i want to reverse the first filed ie 07/25 as 25/07 00:10 d327490 25/07 00:55 d378299 25/07 03:58 d378299 25/07 06:14 d642035 25/07... (5 Replies)
Discussion started by: zozoo
5 Replies

10. Shell Programming and Scripting

Reverse Display of a file

Hi all, Just saw a "sed" format to reverse display the file contents, but am not geting its logic completely. I would appreciate if somebody can explain sed '1!G;h;$!d' < filename All I know in this is that : G will add a new line after every line except first one... (5 Replies)
Discussion started by: dextergenious
5 Replies
XSTR(1) 						      General Commands Manual							   XSTR(1)

NAME
xstr - extract strings from C programs to implement shared strings SYNOPSIS
xstr [ -c ] [ - ] [ file ] DESCRIPTION
Xstr maintains a file strings into which strings in component parts of a large program are hashed. These strings are replaced with refer- ences to this common area. This serves to implement shared constant strings, most useful if they are also read-only. The command xstr -c name will extract the strings from the C source in name, replacing string references by expressions of the form (&xstr[number]) for some number. An appropriate declaration of xstr is prepended to the file. The resulting C text is placed in the file x.c, to then be compiled. The strings from this file are placed in the strings data base if they are not there already. Repeated strings and strings which are suffices of existing strings do not cause changes to the data base. After all components of a large program have been compiled a file xs.c declaring the common xstr space can be created by a command of the form xstr This xs.c file should then be compiled and loaded with the rest of the program. If possible, the array can be made read-only (shared) sav- ing space and swap overhead. Xstr can also be used on a single file. A command xstr name creates files x.c and xs.c as before, without using or affecting any strings file in the same directory. It may be useful to run xstr after the C preprocessor if any macro definitions yield strings or if there is conditional code which contains strings which may not, in fact, be needed. Xstr reads from its standard input when the argument `-' is given. An appropriate command sequence for running xstr after the C preprocessor is: cc -E name.c | xstr -c - cc -c x.c mv x.o name.o Xstr does not touch the file strings unless new items are added, thus make can avoid remaking xs.o unless truly necessary. FILES
strings Data base of strings x.c Massaged C source xs.c C source for definition of array `xstr' /tmp/xs* Temp file when `xstr name' doesn't touch strings SEE ALSO
mkstr(1) BUGS
If a string is a suffix of another string in the data base, but the shorter string is seen first by xstr both strings will be placed in the data base, when just placing the longer one there will do. 3rd Berkeley Distribution May 7, 1986 XSTR(1)
All times are GMT -4. The time now is 02:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy