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


ADVERTISEMENT

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

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 :: Remove The Last Character From Variable

Jun 22, 2010

i have the following:

Quote:

echo %host%|sed "$s/.$//"

this would remove the Last character of the value assigned to the %host%. for example if my value is: abcd i get abc. but i am not able to assign the output. for example when i do

Quote:

set k=`echo %host%|sed "$s/.$//"`

after doing echo %k i get no output at the command prompt...!! whereas when i just type:

Quote:

echo abcd|sed "$s/.$//"

at the command prompt i get abc. maybe some other ways to Remove the Last character...?

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

Software :: Environment Variable Names Containing Odd Characters?

Mar 27, 2010

I want to have an environment variable name (not value) containing ':', such as X:X=PQR. There seems to be no reason in principle why not. According to this:[URL].. the only printable character you can't have is '='. And indeed I can set and get such variables with a C program:

#include <stdio.h>
main()
{
setenv("X:X", "PQR", 1);
printf("%s
", getenv("X:X"));

[Code]..

and I can't find a quoting mechanism to make this work. Is there a unix guru out there who knows how to do this in bash, or any other linux shell?

View 5 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: Make A New Variable With The String From The Old Variable Btut Without Any Plus Sign?

Apr 7, 2010

my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.

i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't

foo=+12.40
bar=${foo#+}

View 4 Replies View Related

Programming :: Search Within A Variable And Assign The Results To A New Variable?

Apr 25, 2011

how I can search within a variable and assign the results to a new variable. I'll use the following as an example -

cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`

with the echo command I get the following output assigned to list -

A
C
C

What I'd like to get for output is -

Audi
Cadillac
Chevy

how I could do this regardless of upper/lower case letters?

View 5 Replies View Related

Programming :: Assign Value Of C Variable To Shell Variable?

Apr 28, 2010

included shell script inside c program, and i wanted to assign the value of c variable to shell variable..Can any one please suggest me how to do it?

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

Programming :: Assignment To A Variable Variable?

Mar 17, 2011

This loop is part of a bash script which takes multiple arguments.

Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))

[code]...

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

General :: Remove A Certain Character From A Variable?

Jun 15, 2010

I want to remove single quote from a variable. eg: Suppose I have a variable VAR='TEST' (including single quotes) How can I remove single quotes and make it TEST.

View 5 Replies View Related

General :: Remove Lines With Variable Value?

Jul 20, 2011

I have model output data in ascii format. It contains thousands of lines. The output file contains multiple text lines with variable values. here I copy-paste some of it's contents.

Code:

73438 170 23:53:20 3.481328E-03 1.824611E+04 1.824612E+04 1.333962E+16
73439 170 23:56:40 3.481210E-03 1.824611E+04 1.824612E+04 1.333962E+16
73440 171 00:00:00 3.481093E-03 1.824611E+04 1.824612E+04 1.333962E+16

[code]....

i want to remove the lines starting by WRT and DEF.

View 7 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

Programming :: Control Characters In C

Feb 16, 2009

I'm working on my ncurses application, written in C. I get user input through a loop which uses getchar(). I was able to recognize Ctrl-n by comparing the keypress to ASCII character 16, and this seems to work fine. However, if I noticed that the ASCII character for Ctrl-j (10) is the same as the Line Feed. I tested this, and if I press enter on the keyboard I get the same ASCII value as when I press Ctrl-j.

So, what do I do if I want Ctrl-j to mean something different in my program than pressing enter?The ncurses terminal mode is set to raw, with a 100 millisecond timeout, and keypad is on (I'm already using the up and down arrow-keys).

View 1 Replies View Related

Programming :: How To Do An Array Of Characters

Feb 18, 2010

I am trying to create an array containing all ASCII characters, how do I create one:

Code:
#!/bin/bash
CHARLIST=( a b c d e f g h i j k l m n o p q r s t u v w x y z

[code]...

View 6 Replies View Related

Programming :: Scramble Characters In AWK?

May 12, 2010

I see I'm finally posting an AWK question rather than an answer for a change I wanted to make an AWK script that would scramble all the characters in each field, but leave the first and last characters where they were.

View 14 Replies View Related

Programming :: How To Truncate Last Two Characters If Its '_1'

Mar 17, 2010

In a file i have to grep for a particular word and cut 8 characters of that word and replace the last characters with space if it is _1.Eg: HP4350_1..i did grep|cut -c 2-9|but didn't know how to truncate the last two characters if its '_1'.i used tr '[_1] '[ ]'.but it replaced all the characters where there is a 'underscore' and 1 instead of'_1' together.

View 5 Replies View Related

Programming :: Stripping Characters Before '=' Delimiter In PHP?

Aug 15, 2010

I'm trying to make a webpage that will display the bash variables I have in a file. These variables are used in a bash script that is run from on my server.The file looks like this:

SERVER=canfs01
SHARE=public
USERNAME=guest

[code]....

View 7 Replies View Related

Programming :: Eclipse And C++ Misrepresentation Of Characters

Mar 3, 2011

I just started using eclipse. Ie, I followed all the instructions to set up C++ and run a simple hello world program.However, I seem to have hit a snag.When I build the solution I get an error. I realized where there should be a > there is a | instead. Every time I type > the | prints instead and I have no idea how to fix this.

View 3 Replies View Related

Programming :: Split A String By Every Nth Characters?

Jan 17, 2011

splitting a string by every nth characters. I'm using Python 2.7.1 because I'm using older libraries, if that matters.

For example, if this is my input:

Quote:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac elit nibh, vitae venenatis ligula. Vestibulum a varius turpis.

Splitting it by every 10th character should produce this list:

Quote:

[ "Lorem ipsu", "m dolor si", "t amet, co", "nsectetur ", "adipiscing", " elit. Sed", " ac elit n", "ibh, vitae", " venenatis", " ligula. V", "estibulum ", "a varius t", "urpis." ]

View 6 Replies View Related

Programming :: Displaying Unicode Characters

Feb 19, 2011

I wrote a java program that writes strings to a file. The strings contain foreign language characters. When I run the program in Windows, the output file shows the foreign characters. However, when I attempt the same operation in Linux, the output file shows a white question mark in a black background instead of the foreign characters. The same Linux system could display the foreign characters if I copy the output file from Windows to Linux. I tried to create the output file using gedit that my program would then add additional strings to and chose Unicode-32 for encoding but still the same problem.

What could I do to get the program to display the foreign language characters from output text file?

View 6 Replies View Related

Programming :: Escape Characters In System?

Nov 11, 2010

My goal is to send escape characters from Linux to make scanner's LED blink. I've started with a simple "beep" command:
echo -e "�7"

and it worked. We are using WaveLink emulator and the escape sequences for the LED are
echo -e "�33%150;200;5L"

Linux returns me this: 150;200;5L
So, it doesn't work. What am I doing wrong for the LED sequences?

View 1 Replies View Related







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