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


ADVERTISEMENT

Programming :: Remove Characters From Within Variable

Feb 20, 2011

I am doing a mysql query with a bash shell script like:
mysql translator -u root --password=******** -e "SELECT word FROM tagalog ORDER BY RAND() LIMIT 1" | while read line; do
echo $line

So when I echo the value of $line I get:
word
magandang umaga
"word" is the name of the row in the table and maganda umaga is a randomly selected choice from the row. Is there a way i can remove the name of the row from the variable $line. With a result that will allow me to echo $line and output only the randomly selected entry in from the row e.g. magandang umaga

View 13 Replies View Related

Programming :: Replacing Set Of Characters In A Specific Line Using Sed Or Awk?

Dec 29, 2010

I would like to replace 'xxxx' with 'yyyy' which is in a file xyz.csproj not sure of what 'xxxx' is, it can be 3055, 4056, 7089 etc. I know it always appears at line # 5 and at character 50.

<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Windows.Forms" />

[code]....

View 14 Replies View Related

Programming :: Remove All Lines Containing Extended Characters

Nov 7, 2010

I am using 'sed -e /foo/d' to match lines which I want to delete from a file. I discovered I have some lines which contain random (extended?) characters like 'ủ' which I would also like to delete. The lines in the file should only contain alpha numeric characters.

View 8 Replies View Related

Programming :: Remove Characters From Grep Output?

Apr 14, 2010

How can I remove characters from grep output using sed? code...

View 9 Replies View Related

Programming :: Remove Special Characters From String

Jan 30, 2011

I am reading strings from a file using readline() function,the file contains some strings which has only special characters, I need to avoid the strings which has only special characters, the special characters are not similar. How to do it in python.??

View 2 Replies View Related

Programming :: Remove Odd Characters From CSV Files Using A Script?

Apr 27, 2010

I hope you can help. I have a collection of spreadsheets with data that needs to be imported in to SQL. The data has been manually entered although there are portions where data has been copied and pasted from the web.

When converting these sheets to a CSV I get strange characters where it looks as though data has been copied and pasted. Is it possible to write a script (AWK?) to pull out these characters?

I guess the script will need to keep alpha characters, spaces, numerics and commas but nothing else. How easy is this to do?

View 7 Replies View Related

Programming :: Remove All Alphabetic Characters At Beginning Of String

Jul 26, 2010

I am working with a Tcl script and have some strings in the following format (RE):
[a-zA-Z]+[0-9]{6}-[0-9]

There are some leading letters, combinations of capital and lowercase. Then six digits, followed by a hyphen, then one more digit. I would like to remove all of the leading alphabetic characters from the string. The resulting string would then be in this format: [0-9]{6}-[0-9]. In other words, six numeric digits, a hyphen, then one more digit.

I have tried:
Code:
set newstr [string trimleft $origstr alpha]
But that only removes the first alphabetic character, not all of them.

I couldn't get anything with regsub to work correctly, but I am somewhat of a noob with RE's in general and regsub in particular. There are usually 5 leading letters at the beginning of these strings, and I could in most cases get away with using string replace and constant indices to extract the substring. However, my preference is for this to be robust enough to handle all cases with 1 through n leading alphabetic characters.

View 3 Replies View Related

Programming :: Change A Line In A File Code - Sed Special Characters Bash Script

Jan 26, 2011

I'm having issue when trying to change a line in a file

[Code]....

View 1 Replies View Related

Programming :: Remove Line Break If Next Line Does Not Start With "PX"?

May 25, 2011

I have a big csv-file wich is not formatted very well. I clean it up with removing a lot of html etc, but some of the lines breaks where they are not supposed to.What I want to do is to check next line, if it starts with 'PX' I don't want to do anything, but if it does not start with 'PX' I want to merge the two lines. That is removing the newline character on line one and replace it with a space.Can this be done with sed? (or maybe with perl or something, but I'm more familiar with sed)I've been looking und the net to find a solution, but to no result.

View 8 Replies View Related

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 View Related

Programming :: Shell To Remove Line Matched With Variable?

Jul 25, 2011

I'm using sed to remove certain line in a text file based on a match with 2 variables from input. Here is how it looks like in file

Philip S:Odds:45:343
Mike Junior:Odds:3:56

I prompt for 2 inputs in variable form which is compared to the first 2 fields of the above text (: seperated). So say i enter Philip S and Odds then it should delete the entire first line.

View 4 Replies View Related

Programming :: Using Sed To Remove Line In A Comma-delimited File?

Mar 10, 2009

I have a script that output all my data in to a comma-delimited file separated by ";"

Current Output:

Quote:

"SAP 1117A";10.94.1.7;239.234.1.12;0;0;0;0;0;3;172.31.207.45;""
"";NA;239.192.1.50;0;0;0;0;0;3;172.31.207.61;""
"";NA;239.192.1.50;0;0;0;0;0;3;172.31.207.62;""

[code]...

I would like to remove all lines that have an NA in the second field.

New Output

Quote:

"SAP 1117A";10.94.1.7;239.234.1.12;0;0;0;0;0;3;172.31.207.45;""
....

View 4 Replies View Related

Programming :: Remove Line Containing Certain Variable - Bash - Permission Denied?

Jul 20, 2011

I am writing a bash script to run everyday and output results to a file. When the same results are produced i want to overwrite the line from the previous day. (Or remove and add). So if the script finds a variable in a line. i want it to output the results to that line . sed -i did not work for me; sed: couldn't open temporary file ./sedTvOCEg: Permission denied

View 10 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

Software :: Remove Particular Characters Using Sed

Dec 13, 2010

file = TT.ParlayX_RequestLog_78653_20101212180044.log.17490
1. Want to remove the characters before the first dot (.) including the dot (.)
2. Want to remove the characters after the last dot (.) including the dot (.)

That is, basically, I want the output as:
ParlayX_RequestLog_78653_20101212180044.log

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

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

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

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 :: 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

Software :: Filter Printed Line To Get Characters Between 2 Expressions?

Jan 28, 2011

I'm having trouble getting a sed command to work. I need to filter a printed line to get characters between 2 expressions. "<job>" and "<url>".

Code:
echo "<job>TEST<url>http://www.project.com/?code=001" | sed 's/^[<job>]*//' | sed 's/[<url>]*$//'
Produces:
Code:
TEST<url>http://www.project.com/?code=001

It takes off the first part but why is that not deleting the "<url>" and all the parts after that?

View 9 Replies View Related

General :: Remove Extra Characters From Multiple Files

Sep 18, 2011

I have a directory (Linux user) with a number of files which contain an added [!] to the end of each file name so that each file reads out as:
foo something [!].zip
bar something [!].zip
helloworld [!].zip
etc.
What is the quickest way to batch rename these to remove the ending [!] character combination from these file names?

View 2 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 :: 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 :: 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







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