Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Select only certain lines from file and mantain formatting Post 302252923 by radoulov on Thursday 30th of October 2008 03:46:13 PM
Old 10-30-2008
Use nawk or /usr/xpg4/bin/awk on Solaris:

Code:
awk -F'\n' '{print$1,$NF}' RS= infile

With Perl:

Code:
perl -00 -F'\n' -ane'print"$F[0] $F[-1]\n"' infile


Last edited by radoulov; 10-30-2008 at 04:51 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

formatting the sql select result

Hi, I have about 12 columns and 15 rows to be retrived from sybase isql command through unix. But when i output the sql into a file and see it, the formatting is going for a toss. can someone please suggest how can i get the result correctly in the output file ? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies

2. Shell Programming and Scripting

Select some lines from a txt file and create a new file with awk

Hi there, I have a text file with several colums separated by "|;#" I need to search the file extracting all columns starting with the value of "1" or "2" saving in a separate file just the first 7 columns of each row maching the criteria, with replacement of the saparators in the nearly created... (4 Replies)
Discussion started by: capnino
4 Replies

3. Shell Programming and Scripting

Select lines in which column have value greater than some percent of total file lines

i have a file in following format 1 32 3 4 6 4 4 45 1 45 4 61 54 66 4 5 65 51 56 65 1 12 32 85 now here the total number of lines are 8(they vary each time) Now i want to select only those lines in which the values... (6 Replies)
Discussion started by: vaibhavkorde
6 Replies

4. Shell Programming and Scripting

sql select command output formatting in shell script

Hi, I need to connect to the database and retrieve two variables from the database and store them in a variable,out of these two variables I need to get lastdigit appended to the variable 1 retrieved and variable 2 with out any modification in short select var,data from usage; o/p=... (1 Reply)
Discussion started by: rkrish
1 Replies

5. UNIX for Dummies Questions & Answers

how to select lines from one file based on another file

Hi, I would like to know how can I select lines of one file based on a common ID column from another file (keeping the order of the second file). Example of file1: ID A B C D 1-30 1 2 3 5-60 4 5 6 1-20 7 8 9 Example of file2: ID chr pos 1-20 1 20 1-30 1 30 5-60 5 60 Desired... (2 Replies)
Discussion started by: fadista
2 Replies

6. UNIX for Dummies Questions & Answers

How to randomly select lines from a text file

I have a text file with 1000 lines, I want to randomly select 200 lines from it and print them as output. How do I go about doing that? Thanks! (7 Replies)
Discussion started by: evelibertine
7 Replies

7. Shell Programming and Scripting

Short program to select lines from a file based on a second file

Hello, I use UBUNTU 12.04. I want to write a short program using awk to select some lines in a file based on a second file. My first file has this format with about 400,000 lines and 47 fields: SNP1 1 12.1 SNP2 1 13.2 SNP3 1 45.2 SNP4 1 23.4 My second file has this format: SNP2 SNP3... (1 Reply)
Discussion started by: Homa
1 Replies

8. Shell Programming and Scripting

Select lines from a file based on a criteria

Hi I need to select lines from a txt file, I have got a line starting with ZMIO:MSISDN= and after a few line I have another line starting with 'MOBILE STATION ISDN NUMBER' and another one starting with 'VLR-ADDRESS' I need to copy these three lines as three different columns in a separate... (3 Replies)
Discussion started by: Tlcm sam
3 Replies

9. Shell Programming and Scripting

awk - mixed for and if to select particular lines in a data file

Hi all, I am new to AWK and I am trying to solve a problem that is probably easy for an expert. Suppose I have the following data file input.txt: 20 35 43 20 23 54 20 62 21 20.5 43 12 20.5 33 11 20.5 89 87 21 33 20 21 22 21 21 56 87 I want to select from all lines having the... (4 Replies)
Discussion started by: naska
4 Replies

10. Shell Programming and Scripting

Select only the lines of a file starting with a field which is matcing a list. awk?

Hello I have a large file1 which has many events like "2014010420" and following lines under each event that start with text . It has this form: 2014010420 num --- --- num .... NTE num num --- num... EFA num num --- num ... LASW num num --- num... (9 Replies)
Discussion started by: phaethon
9 Replies
slp(1)							      General Commands Manual							    slp(1)

NAME
slp - set printing options for a non-serial printer SYNOPSIS
cols] indent] lines] pages] pages] DESCRIPTION
sets printer formatting options such as the number of lines per page, number of characters per line, and indentation. These characteris- tics are controlled by the printer driver as described in lp(7). acts on the current standard output. Options recognizes the following options and arguments: Report all option settings. Specify a character printer where backspace characters pass through the driver unchanged. The absence of this option indicates a line printer. The driver takes the necessary action to accommodate backspace characters. Resets the printer back to line-printer mode. Limit the number of columns to be printed to cols. Characters beyond the specified limit are truncated. Reset options to default for the device. This action is not taken until the next open occurs on the device. Indent indent columns before printing the first column. Select cooked mode. Cooked mode must be used with a cooked device special file which is identified by an lp mnemonic that is not preceded by the character Specify the number of lines per page. The last new-line character of each page is changed to a form-feed. Set the page size to infinity. Since the last new-line of the page is never encountered, no new-line characters are changed to form-feeds. Select a raw mode for graphics dumps. All other options are ignored except If the option is not given, is assumed. Eject zero or more pages after the final close of the device. Eject zero or more pages when the device is opened. EXAMPLES
In a typical case, the printer is set to 80 columns, no indentation, with no form-feeds between pages: WARNINGS
Use of the command in conjunction with the spooler (see lp(1)) might cause undesirable side effects. The spooler model files make assump- tions regarding the configuration and can get confused when the default values are altered. Although most options can be altered without difficulty, special problems sometimes result from adjusting the number of lines and the number of columns per page. AUTHOR
was developed by HP. SEE ALSO
lp(1), ioctl(2), lp(7). slp(1)
All times are GMT -4. The time now is 11:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy