Sponsored Content
Full Discussion: Swapping lines
Top Forums Shell Programming and Scripting Swapping lines Post 303027820 by Kibou on Tuesday 25th of December 2018 12:04:54 PM
Old 12-25-2018
@Scrutinizer Unfortunately doesn't work either. I've tried a few modifications but it only prints the first three lines.

@MadeInGermany It works, but for some reason the text is all the way around. The comments at the beginning show at the end.

I don't want to bother you guys that much. I thought this could be easier....
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Swapping questions

How can you tell how much a Solaris box is swapping? At what point do page in and page out become a problem? Here is a vmstat output. > vmstat procs memory page disk faults cpu r b w swap free re mf pi po fr de sr m0 m1 m2 m3 in sy cs us sy id... (1 Reply)
Discussion started by: 98_1LE
1 Replies

2. SuSE

Swapping

Hello! Why does my SuSE GNU/Linux machine swap? I have a Gig of ram, currently 14MBs of free RAM, 724MB - buffers and caches... That is 685MB of cached RAM, then kernel really should'nt have to swap, It should release cached memory in my thinkin... It has only swaped 3MB's but still,... (3 Replies)
Discussion started by: Esaia
3 Replies

3. Shell Programming and Scripting

Swapping or switching 2 lines using sed

I made a script that can swap info on two lines using a combination of awk and sed, but was hoping to consolidate the script to make it run faster. If found this script, but can't seem to get it to work in a bash shell. I keep getting the error "Too many {'s". Any help here would be appreciated:... (38 Replies)
Discussion started by: LaTortuga
38 Replies

4. Shell Programming and Scripting

Swapping lines beginning with certain words using sed/awk

I have a large file which reads like this: fixed-address 192.168.6.6 { hardware ethernet 00:22:64:5b:db:b1; host X; } fixed-address 192.168.6.7 { hardware ethernet 00:22:64:5b:db:b3; host Y; } fixed-address 192.168.6.8 { hardware ethernet 00:22:64:5b:db:b4; host A; }... (4 Replies)
Discussion started by: ksk
4 Replies

5. Shell Programming and Scripting

swapping lines that match a condition using sed, perl or the like

I'm a bit new to regex and sed/perl stuff, so I would like to ask for some advice. I have tried several variations of scripts I've found on the net, but can't seem to get them to work out just right. I have a file with the following information... # Host 1 host 45583 { filename... (4 Replies)
Discussion started by: TheBigAmbulance
4 Replies

6. Shell Programming and Scripting

Swapping three lines

I have some text: <date>some_date</date> <text>some_text</text> <name>some_name<name> and I want to transform it to smthng like that: some_name on some_date: some_text I've tried sed: sed 's/<text>\(.*\)<\/text> <name>\(.*\)<\/name>/\2 - \1/' but it says unterminated... (13 Replies)
Discussion started by: dsjkvf
13 Replies

7. Shell Programming and Scripting

AWK swapping fields on different lines

Hi All, Sorry if this question has been posted elsewhere, but I'm hoping someone can help me! Bit of an AWK newbie here, but I'm learning (slowly!) I'm trying to cobble a script together that will save me time (is there any other kind?), to swap two fields (one containing whitespace), with... (5 Replies)
Discussion started by: Bravestarr
5 Replies

8. Shell Programming and Scripting

Swapping fields

Hallo Team, This is the command that i am running : grep ",Call Forward Not Reachable" *2013* this is the output that i am getting (i did a head -10 but the files can be more than 1000) ... (8 Replies)
Discussion started by: kekanap
8 Replies

9. Shell Programming and Scripting

Swapping the 1st 4 lines only

How can you swap the first 4 line only, the rest will stay the same. thanks #!/bin/sh line=4 awk -v var="$line" 'NR==var { s=$0 getline;s=$0"\n"s getline;print;print s next }1' fileko.tx . desired output: (8 Replies)
Discussion started by: invinzin21
8 Replies

10. Solaris

Swapping

Hi Guys I am using SPARC-T4 (chipid 0, clock 2998 MHz), SunOS 5.10 Generic_150400-38 sun4v. How do I see if the server was doing some swapping like yesterday? I had a java application error with java.lang.OutOfMemoryError, now I want to check if the server was not doing some swapping at... (4 Replies)
Discussion started by: Phuti
4 Replies
STRFILE(1)						   UNIX System Manager's Manual 						STRFILE(1)

NAME
strfile - create a random access file for storing strings unstr - dump strings in pointer order SYNOPSIS
strfile [-iorsx] [-c char] sourcefile [outputfile] unstr [-c char] datafile[.ext] [outputfile] DESCRIPTION
strfile reads a file containing groups of lines separated by a line containing a single percent `%' sign (or other specified delimiter character) and creates a data file which contains a header structure and a table of file offsets for each group of lines. This allows ran- dom access of the strings. The output file, if not specified on the command line, is named sourcefile.dat. The purpose of unstr is to undo the work of strfile. It prints out the strings contained in the sourcefile, which is datafile.ext without its extension, or datafile if no extension is specified (in this case, the extension .dat is added to the name of the datafile) in the order that they are listed in the header file datafile. If no outputfile is specified, it prints to standard output; otherwise it prints to the file specified. unstr can also universally change the delimiter character in a strings file. It is possible to create sorted ver- sions of input files by using strfile -o and then using unstr to dump them out in the table order. Options The options are as follows: -c char Change the delimiting character from the percent sign to char. This option is available for both strfile and unstr. -i Ignore case when ordering the strings. -o Order the strings in alphabetical order. The offset table will be sorted in the alphabetical order of the groups of lines refer- enced. Any initial non-alphanumeric characters are ignored. This option causes the STR_ORDERED bit in the header str_flags field to be set. (It also now really does sort! It didn't used to). -r Randomize access to the strings. Entries in the offset table will be randomly ordered. This option causes the STR_RANDOM bit in the header str_flags field to be set. (And really does randomize) -s Run silently; don't give a summary message when finished. -x Note that each alphabetic character in the groups of lines is rotated 13 positions in a simple caesar cypher. This option causes the STR_ROTATED bit in the header str_flags field to be set. Note that it does not rotate the strings--that operation must be per- formed separately. Header The format of the header is: #define VERSION 1 unsigned long str_version; /* version number */ unsigned long str_numstr; /* # of strings in the file */ unsigned long str_longlen; /* length of longest string */ unsigned long str_shortlen; /* shortest string length */ #define STR_RANDOM 0x1 /* randomized pointers */ #define STR_ORDERED 0x2 /* ordered pointers */ #define STR_ROTATED 0x4 /* rot-13'd text */ unsigned long str_flags; /* bit field for flags */ char str_delim; /* delimiting character */ All fields are written in network byte order. BUGS
Fewer now, one hopes. However, fortunes (text strings) beginning with a blank line appear to be sorted between random letters. This includes ASCII art that contains no letters, and first lines that are solely non-alphanumeric, apparently. I've no idea why this should be. OTHER USES
What can you do with this besides printing sarcastic and obscene messages to the screens of lusers at login or logout? There are some other possibilities. Source code for a sample program, randstr, is included with this distribution: randstr splits the dif- ference between unstr and fortune. It reads a single, specified file, and randomly selects a single text string. 1 Include strfile.h into a news reading/posting program, to generate random signatures. Tin(1) does something similar, in a much more complex manner. 2 Include it in a game. While strfile doesn't support 'fields' or 'records', there's no reason that the text strings can't be consis- tent: first line, a die roll; second line, a score; third and subsequent lines, a text message. 3 Use it to store your address book. Hell, some of the guys I know would be as well off using it to decide who to call on Friday nights (and for some, it wouldn't matter whether there were phone numbers in it or not). 4 Use it in 'lottery' situations. If you're an ISP, write a script to store login names and GECOS from /etc/passwd in strfile format, write another to send 'congratulations, you've won' to the lucky login selected. The prize might be a month's free service, or if you're AOL, a month free on a real service provider. SEE ALSO
byteorder(3), fortune(6) HISTORY
The strfile utility first appeared in 4.4BSD. This version was heavily modified, much of it in ways peculiar to Linux. Work has since been done to make the code more generic, and has so far been tested to work with SunOS 4.x. More platforms are expected to be supported as work continues. 4th Berkeley Distribution June 9, 1993 [Apr. '97] STRFILE(1)
All times are GMT -4. The time now is 06:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy