General :: Sort By Line Size (number Of Characters In A Line)?

Jan 8, 2010

I want to sort a number of lines based on their size:

data:
-------
12345678
87654321
1234

[code]....

Should output as:
-----------------
1
2
12
21

[code]....

But i'm gettings this with sort
----------------
1
12
123
1234

[code]....

Can we sort the above "data" text, based on "number of characters" instead of "character order"?

View 8 Replies


ADVERTISEMENT

OpenSUSE :: Change The Number Of Characters Per Line For Konsole?

Dec 21, 2010

Probably an easy question but my googlefu is weak. How do I change the number of characters per line for konsole?

View 6 Replies View Related

General :: Getting The Line Of String From Previous Pipe Output By Line Number?

Feb 8, 2010

After running the following command, I get:

[root@yukiko /]# find / -iname .bashrc
/home/clamav/.bashrc
/home/vpopmail/.bashrc
/etc/skel/.bashrc
/root/.bashrc

But I would like to have a command that prints a specific line by supplying the command with the line number, for example:

[root@yukiko /]# find / -iname .bashrc | getline(2)
/home/vpopmail/.bashrc

Is there such a command on CentOS?

View 3 Replies View Related

Programming :: Insert Line Using Sed Or Awk At Line Using Line Number As Variable

Jul 25, 2011

I want to insert a line at a particular line number using sed or awk. where line number is not fixed and is in form of variable.

I want to use variable in sed or awk command.I tried something like below, but no luck.

View 7 Replies View Related

General :: How To Delete A Line At Specific Line Number

Jun 15, 2010

I m writing a script to delete a line at particular location.

But i m unable to use variable for specifying line number.

For example.

Code:

works fine and deletes 7th line from my file

But

Code:

gives following error.

Code:

View 7 Replies View Related

General :: Sed - Print Line Number Along With The Line?

Jan 30, 2011

I want to print the line number with the pattern of the line on a same line using multi-patterns in sed. But i don't know how to do it. For example, I have a file

abc
def
ghi

I want to print

1 abc
2 def
3 ghi

View 6 Replies View Related

Programming :: Create File Listing In C++ That Will Generate Line Number On Every Line Of Code

Apr 11, 2010

I have a project due for my Intro to C++ class and we are suppose to generate a file listing that will take an input of a C++ source code with .cpp extension and make a copy of it with a .lst extention that will have a line number preceding each and every line.

View 12 Replies View Related

Programming :: BASH Sort List By End Of Line To X Position In Each Line?

Aug 18, 2010

I'm trying to make another file annotation script a little speedier than it has been by the up-until-now proven method of checking the last four characters in a filename before the "dot" (eg .jpg, .psd) against a list of known IPTC categories and Exiv2 command files. It occurred to me that if one script generated a list of files in directory foo, and the same or another script sorted that list by that four-letter tag,then that list could be used(instead of a for/do/done loop on the real files in the folder) by the command-file-matching script to "vomit out" which annotator file would go with file nastynewfile.jpg, f'r'instance. The script I had been using for this task looks like this:

Code:

while read 'line';
do
sp=$(echo $line)
vc=$(echo $sp | cut -d"," -f1)
cv=$(echo $sp | cut -d"," -f2)

[code]....

Where I seem to be stuck is with how to sort the lines in templist, which may be any number of different lengths, from back to front. sort -k looked promising, except it seems only to work the other way round. I thought of invoking a

Code:

q=$(expr length $line); echo $q
n=$[q-8]; echo $n

kind of thing, but that presented the problems of how to sort by those, how to tell sort where to find them (grep?) and how to "stitch them back in" to the original list, which is what I want to sort in the first place.

View 14 Replies View Related

General :: How To Put Some Characters On The End Of A Line

Nov 1, 2010

We have a list of cyclones in the world. Now i got to check whether or not the second field is more than 1000 mm. If so, than the line has to have a[*] at the end of the line. For exemple:

Australia:1411:55.55:Mackay Cyclone 1918:1918:Mackay
to
Australia:1411:55.55:Mackay Cyclone 1918:1918:Mackay[*]

I also have to use a substitute. So far i've got this but it fails, 6,$s/([0-9])111:1/.* [*]

View 7 Replies View Related

General :: Moving Characters To The End Of Line (EOL) With SED?

Sep 13, 2010

Any time the word The appears at the beginning of a line, I want to move it to the end of the line and capitalize the new first word in the line. For example, The heaven becomes Heaven the. I'm trying to test this out for my Library.

View 2 Replies View Related

General :: How To Strip/trim Characters In Command Line

Mar 23, 2011

I have a bunch of files (around 900) that have some special characters. Some of the files contains example, and quoting "[useless] filename (something)"so what I want is just to strip the brackets and parenthesis, some are folders, others are text files

View 1 Replies View Related

General :: PuTTY And 256-color - Line Drawing Characters ?

May 3, 2011

I'm having trouble setting up PuTTY with Ubuntu. I'm trying to get line characters to work in aptitude as well as 256-color support, but can only get one or the other.

Ubuntu Config:

Using 64-bit Ubuntu
Terminal type xterm-256color or putty-256color gives 256-color, but incorrect line characters.
Terminal type linux gives proper lines in aptitude, but only 16 colors.

PuTTY Config:

Using font with Unicode characters. (DejaVu Sans Mono)
Received Data is assumed to be in UTF-8.
Set to use Unicode line drawing code points.

Output from locale:

View 1 Replies View Related

General :: Playing With Various Characters In The Command- Line Interface?

Apr 23, 2010

I am playing with various characters in the command- line interface trying to learn what they mean and when i should use them.

View 7 Replies View Related

General :: Replace New Line With <br /> And Escape Special Characters?

Feb 6, 2011

I wish to replace a new line with br (html) but it doesn't seem to work

Code:

message=$(echo ${FORM_message} | tr '
' '<br />' )

what it gives me seems to be ... b...? I am also having problem escaping hash sign in cut command:

Code:

list=$(echo "$line" | cut -d'#;#' -f1) ;

my intention is to split the line with "#;#"

View 5 Replies View Related

General :: Bash : Pass Command Line Arguments Containing Special Characters?

Jul 14, 2010

I've written myself a linux program "program" that does something with a regular expression. I want to call the program in the bash shell and pass that regular expression as a command line argument to the program(there are also other command line arguments). A typical regular expression looks like "[abc]_[x|y]".Unfortunately the characters [, ], and | are special characters in bash. Thus, calling "program [abc]_[x|y] anotheragument" doesn't work. Is there a way to pass the expression by using some sort of escape characters or quotation marks etc.?

(Calling program "[abc]_[x|y] anotheragument" isn't working either, because it interprets the two arguments as one.)

View 7 Replies View Related

General :: Bash: How To Pass Command Line Arguments Containing Special Characters

Jun 24, 2011

I've written myself a linux program "program" that does something with a regular expression. I want to call the program in the bash shell and pass that regular expression as a command line argument to the program (there are also other command line arguments). A typical regular expression looks like "[abc]_[x|y]". Unfortunately the characters [, ], and | are special characters in bash. Thus, calling "program [abc]_[x|y] anotheragument" doesn't work. Is there a way to pass the expression by using some sort of escape characters or quotation marks etc.? (Calling program "[abc]_[x|y] anotheragument" isn't working either, because it interprets the two arguments as one.)

View 8 Replies View Related

General :: Bash Script To Parse A File To Get A Set Of Line Between A Specific Characters?

Dec 23, 2010

I have a log file that contains information like this:

----------------------------
r11141 | prasath-palani | 2010-12-23 16:21:24 +0530 (Thu, 23 Dec 2010) | 1 line
Changed paths:
M /projects/
M /projects/

[code]....

what i need is, i need to copy the data given between the "---" to seperate files, for, e.g. the first set of data between the "---" should be in one file and another set of data in another file.

View 5 Replies View Related

General :: Sed: Replace An Unknown Number Of Patterns On The Same Line?

Jul 5, 2011

I'm trying to use sed to search for a certain 'primary' pattern that may exist on several lines, with each primary pattern followed by an --unknown-- number of 'secondary' patterns.The lines containing the pattern start with: test(header_name)On that same line is an arbitrary number of strings that come after it.I want to move those strings over to their own lines so that they each are preceded by their own test(header_name).e.g. Original file (mytest.txt):

apples
test("Type1", "hat", "cat", "dog", "house");
bananas

[code]....

View 2 Replies View Related

General :: Vi Editor - Move Cursor To A Specified Line Number?

Dec 6, 2010

I am using Vi editor for editing and configuring my file.I am facing a little problem when there is long file like 3000 lines. Normally i use

Code:

:set number

in vi editor to visible my line number.The problem is when i have to go in the top of the file like say line number one I use k for it and to move down I use j which is too much time consuming. How can i jump directly my cursor to line number 2333 or line number 2600.

View 4 Replies View Related

General :: Sed - Csv Averages On Command Line - Take The Average Of All Rows With The Same 1st Number(key)

Jul 20, 2010

I have a big file full of records like this

1, 2, 4, 5, 6
1, 3, 5, 6, 3
1, 4, 5, 6, 6
2, 4, 5, 5, 5
2, 3, 4, 5, 2

anyway i need to take the average of all rows with the same 1st number(key). i.e.

1, 3, 4.66, 5.66, 5
2, 3.5, 4.5, 5, 3.5

I know this is something awk/sed would be great for, i just dont have enough experience with them to accomplish it, Also, what about averaging those columns together? so, after I output this to a file, id like to get another like:

1, 4.58
1, 4.125

The number of colums to add might not always be 4 either. EDIT: this might be easier to do in gnuplot, so I mainly just need an answer to the first part.

View 3 Replies View Related

General :: 'automate' That 'rows Selected' Preceded By Number Is Always Last Line

Jul 22, 2010

I'm not that familiar with sed and awk in order to be able to solve this problem on my own, so I'm calling on you for a bit of assistance. I'm writing a Nagios plugin to check our Oracle tablespaces and the output is given in one line like this: 1.04007771 TEMP 0 UNDOTBS1 .005340579 USERS 0 7 rows selected. I've been playing around with sed like below to delete the obsolete info and change every second space into a newline:

[code]...

how many tablespaces there are so I'd have to check all databases and 'hardcode' the tablespaces in my script. Is there any way to 'automate' this knowing that 'rows selected' preceded by a number is always the last line and using a sort of counter to auto-adjust the number to put in the -e 's/ / /2' part?

View 7 Replies View Related

Programming :: Copy And Replacing Specific Line From File1 To File2 Line By Line

Mar 22, 2011

I have two files, file1.traj and file2.traj. Both these files contain identical data and the data are arranged in same format in them. The first line of both files is a comment.

At line 7843 of both files there is a cartesian coordinate X, Y and Z ( three digits ). And at line 15685 there is another three digits. The number of lines in between two cartesian coordinates are 7841. And there are few hundreds of thousands of lines in a file.

What I need to do is copy the X Y Z coordinate (three digits) from file1.traj at line 7843 and paste into file2.traj at the same line number as in file1.traj. The next line will be 15685 from file1.traj and replace at line 15685 at file2.traj. And I dont want other lines (data) in file2.traj get altered. This sequence shall be going on until the end of the file. Means copy and substitude the selected lines from file1.traj into file2.traj.

I tried to use paste command but I cant do for specified line alone.

Here i showed the data format in the file. I used the line number for clarity purpose.

Code:

View 10 Replies View Related

General :: Command Line - Count Number Of Folders In A Drive Using System?

Apr 9, 2010

I need to organise an external HDD such that there is no more than 500 folders on it.

Ubuntu's "Properties" pane shows only the file count, not the folder count.

Is there a simple CLI line that will tell me the number of subdirectories?

View 3 Replies View Related

Programming :: Access A File Line By Line, And Check The Length Of Each Line.

Feb 13, 2011

I want to access a file, and check the length of every line.After, i want to check and replace all lines with length over 10 characters, with a message.Does anyone have a clue on that?

View 1 Replies View Related

General :: Find Out The Serial Number Of Hard Disk Through Command Line On OpenSuse 11.2 ?

Jul 12, 2010

I read this thread but

Code:
anisha@linux-uitj:~> su
Password:

[code]...

View 14 Replies View Related

General :: Command Line Options - Listing MP3 Over Certain Size

Jan 6, 2011

How would I list every mp3 over a certain size on an entire hard drive?

View 1 Replies View Related

General :: PCI Cache Line Size Set Incorrectly (64 Bytes) By BIOS/FW

Nov 24, 2010

I have AMD Phenom 8550 triple code processor, with 2.20ghz speed and 4gb ram. I am trying to install Redhat linux 9 first time. I am new to linux. While install system hangs with message

ehci-hcd 00:13.2: PCI device 1002:4396
echi-hcd 00:13.2: irq 10, pci mem f880f800
usb.c: new usb bus registered, assigned bus number 2
PCI:00:13.2 PCI cache line size set incorrectly (64 bytes) by BIOS/FW" expecting 16

how to get rid of this message

View 9 Replies View Related

General :: TIP: Reducing PDF File Size From The Command Line With GhostScript (gs)?

Jan 14, 2011

I've spent hours trying to scan + shrink a multipage PDF documentlosing readability. This is the first time I've ever needed to do this! (I had to scan each page as ".jpg" in order to email and open on another computer, so I could not scan to PDF directly, which I think is why each page was so large; lower DPIs made the text too blurry.)I found this great tip on UbuntuGeek...but anyone can do this if GhostScript is installed:

View 1 Replies View Related

Programming :: Compare Two Files Line By Line And Print The Line Which Is Same?

May 30, 2011

I am trying to write a program in C which compares two files and prints the line that is equal.

Here file1.txt has

and file2.txt has

Note: file2.txt consist of only a single string where as file2.txt has multiple lines. Actually im comparing two files with md5sum values.

Here is the code but it compares only first line of files..but it should compare the whole file1..and sorry iam a beginner in C can any1 sujest some modification to this code so that..it can compare file2 with entire file1

Quote:

View 9 Replies View Related

Programming :: Using Sed To Remove All But The Last 17 Characters On A Line?

Jun 3, 2010

I'm having a bit of a headbanger trying to work this one out. I'm trying to remove all of the characters on a line apart from the last 17. For example, I need to change this:

Code:

00000000000000000089;0bbfaeb8
01000000000000000089;0bcb5948
00000000000000000089;0bcc4c40

[code]....

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved