Programming :: How To Remove Last Two Fields

Apr 27, 2010

I have a filename file-name-here-1.2.3-i486-2.tar I would like to know how to remove the last two fields leaving only: file-name-here-1.2.3

I can use:

x=file-name-here-1.2.3-i486-2.tar
echo ${a%-*}

to remove the last field (after -) but how do i remove the last two in one fell swoop?

View 2 Replies


ADVERTISEMENT

Programming :: Awk: Swap Fields Given A Condition?

Oct 8, 2010

I have a file records as follows:

Jane pepe@pepe.biz
john@pepe.net John
Joe joe@willxyz.org

How can I get that always first field be given name and second one be the mail address?

I've tried

Code:

awk '$1 ~ /@/ { a=$1 ; $1=$2; $2=a; print }' file

But that doesn't worked

View 5 Replies View Related

Programming :: Finding Common Entries In Fields Using Awk?

May 31, 2010

I want to extract all the common entries in the given 3 columns(fields) in the file using awk::can somebody tell me how it can be done in awk...the file is::

NC_000858.pttNC_000858.fnaNC_001403.rnt
NC_001362.pttNC_001436.fnaNC_001407.rnt
NC_001364.pttNC_001503.fnaNC_001488.rnt

[code]....

View 8 Replies View Related

Programming :: Compare Files With Fields Separated With ':'?

Jul 16, 2011

Dear expertsI have files like

ABD : 5869 events, relative ratio : 1.173800E-01 , sum of ratios : 1.173800E-01
VBD : 12147 events, relative ratio : 2.429400E-01 , sum of ratios : 3.603200E-01
SDF : 17000 events, relative ratio : 3.400000E-01 , sum of ratios : 7.003200E-01

[code]....

View 3 Replies View Related

Programming :: Limit In Number Of Fields That Awk Can Handle

Mar 2, 2011

I have a file with 200 000 lines and I want to append the fields of each line based on matching first field. The resulting file should have 70 000 columns but has "only" 18 000. The command I'm using is working perfectly with a smaller file, wich lead to 14 000 columns. Could there be a limit in number of fields that awk can handle ? Here's my awk command :

Code:

awk -F, 'END { for (k in _) print _[k] } { _[$1] = $1 in _ ? _[$1] FS $4 : $1","$4 } ' file > out

Also, this command writes ^M (windows line break) after each columns. Removing them is easy but where do they come from ? Working on Ubuntu 10.10

View 4 Replies View Related

Programming :: Split Fields In A Perl Array?

Dec 16, 2010

I have an array called @logons. How can I step thru the array and split the fields? This is what I have so far, but doesnt work. I got the feeling I the split statement syntax is incorrect.

Code:

print @logons;
foreach my $logons(@logons){
($userid, $ip) = split(',',$logons);

[code]....

Update: Appears the data in @logons has a column header from the mysql query which I used to populate it with. So that code which I was testing does indeed work.

View 10 Replies View Related

Programming :: Bash - Generating A Table With Aligned Fields

Apr 9, 2009

I want to write a function which calculates the space needed between fields, to generate a table with aligned fields, like when you type "ls -l", the operating system generates a table with beautifully aligned fields. I've got this code so far:

Code:

for line in $(cat tmpSearch)
do
line=`echo $line | tr ":" " "`

[code]....

View 2 Replies View Related

Programming :: Show The Output Of These Fields In A Certain Way That Every Record Is Numbered?

Mar 25, 2010

i am reading a database flat file with the "awk" command which has 4 fields separated by colon ":" .I want to show the output of these fields in a certain way that every record is numbered e.g

1.some text
2.some text

Is there a way to do this?

View 14 Replies View Related

Programming :: While Receiving Can Use Functions Like Strchr() To Differentiate These Fields For Sockets?

Apr 15, 2009

constructing a protocol where in it involves sending and receiving different files, so sending data over consists of file name, size of the file and content of the file, so while receiving can i use functions like strchr() to differentiate these fields for sockets? so to allocate memory for file to save i need to have its size.

View 3 Replies View Related

Programming :: Updating A Sequence Of Datetimes In Fields With Unique Contrains

Mar 14, 2010

I am faced with the following problem; I need to update all fields of type datetime without ... with the following sort data:01-01-2010 12:10:30.256 - this is just an example.these fields are restricted with a unique constrained. My question is how can I generate the above sort data, especially the last three numbers with leading point. After that how can I update a table with existing data with this newly generated data so that the fields really do carry unique data.As you probably can read out of my question, I read through the help in pgAdmin and came as far as generating date, maybe datetime but not the .123 number. And a little insert script I found in the help, that I modified as UPDATE resulted in updating only the last generated data in all required fields.

View 7 Replies View Related

Programming :: Formatting Fields And Text Being Displayed From Text File?

Feb 9, 2011

I want to display the contents of a particular log file (simple text file, I mean in Linux). But there is a problem: The contents need to be organized in a fixed format. Have a look at this log file:

sampleLog.txt

Code:

User Name: XYZ
Reported Problems Description: Blah! Blah! Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah!

[code]....

So, while displaying the contents of above file on a web page, I want to format the field names found in the log file: User Name:, Reported Problems Description:, and Remarks:. These fields may contain a variable length of text and no specific line number is assumed for them to appear on.

The desired output should look like this:

User Name: XYZ
Reported Problems Description: Blah! Blah! Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah!

[code]....

Well, what I am trying to do may sound wierd to some of you. The filed "Reported Problems Description:" can possible contain text which embeds colon (.

View 15 Replies View Related

Ubuntu :: Can't Type In Any Text Fields?

May 25, 2010

First, I'm sorry if some one has already posted this but I can't find it. I recently installed Ubuntu 10.04 LTS on my laptop and I have a dual boot between that and Vista. I cannot use Ubuntu for more than an hour or two before it won't let me type in text fields. When this happens, the menues (Applications, System, ect.) stop working also.

I can continue to browse the internet and play music when this happens. The problem can be recreated consistently by using OpenOffice Word Processor. I can not type more than a sentence in OpenOffice before this problem occurs. The only way to fix it is to hold the power button to shutdown.

View 3 Replies View Related

General :: Comparing Two Fields In Two Files Using Awk?

Jul 12, 2011

I have a file1:

Code:

$ cat PF(1).out
Tmp39 PF10271.3 423 ENSP00000326063 488 1.2e-201 41-478
Tmp39 PF10271.3 423 ENSP00000338165 492 1.9e-200 46-479

[code].....

View 14 Replies View Related

General :: AWK: Rm Duplicates Based On Multi Fields?

Feb 7, 2011

I'm trying to use awk to remove rows that are duplicates based on 3 fields, and I want to keep the on that has the higher value in another field. I'm working in C-Shell. For example the below is greped out of a larger data set to use in here as example:

Input (Field separator is a comma:

Code:

4180,-6999,MA,BARNSTABLE,BOURNE,1,1.7,1700,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,3.5,2025,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,1.0,1511,PM,1/26
4180,-6999,MA,BARNSTABLE,BOURNE,1,5.7,0540,AM,1/27

[Cpde]....

View 1 Replies View Related

General :: How To Grab Tricky Fields In A String

Mar 28, 2010

I'm writing a script that picks out the time offset in a string, but am trying to figure out a way to print a field based on a match (likely needs to be regex).

Here are some sample fields:
09.900. Either add -12:-1: 0 to existing offset, or restart the slicer with no offset or with offset=00
09.900. Either add -12:-1:30 to existing offset, or restart the slicer with no offset or with offset=00
09.900. Either add -10: 0:-47 to existing offset, or restart the slicer with no offset or with offset=00

What I need would be "-12:-1: 0" from the first line, for example. I was just using "awk '{print $4}'" originally but because of the damn space in the 1st and 3rd lines by the 0, that doesn't work for me. How to grab those fields correctly for all cases?

View 3 Replies View Related

General :: Scripting: Modifying SQL Fields Dynamically?

Feb 22, 2010

I'm looking for a way to dynamically modify a fied in the SQL file.

Example,

INSERT INTO `TABLE` VALUES(1AADFDF,DFF33D,10023,SOMEDATA, SOMEDATA);
INSERT INTO `TABLE` VALUES(1AADFDF,DFF33D,10098,SOMEDATA, SOMEDATA);

[code]....

The third field in this SQL file is what needs to change to n+1

"10023" needs to change to "1"
"10098" needs to change to "2"
"10123" needs to change to "3"
"10983" needs to change to "4"
etc...

I tried with awk and sed, but since both require the usage of ' (single quote), my variable fails to get updated. I know i can use cut and recreate the sql statememnt, but i believe there should be easier way using sed or awk. Would anyone know of any creative way to get this to work in one-liner? This needs to be a part of the script preferable without making call to external file.

View 1 Replies View Related

General :: Print Separator For All Fields In `join` Utility?

Dec 13, 2010

For example: file a:Tom:blackLily:pinkfile b:Tom:bigKate:smallAnd, the result:join -t: a1 a ot:Tom:black:bigLily:pinkBut what I want is:Tom:black:bigLily::pink

View 2 Replies View Related

General :: Windows - Removing Duplicate Fields In ID3 Tags?

Jan 10, 2011

I have a couple of MP3s that have duplicate fields in their ID3 tags. Let me show you what I mean: This is causing problems with some media players. Is there a tool that can automatically fix these MP3s in batch? I'd prefer a free Windows or Linux program. I'm not afraid to work on the command line if necessary.

View 2 Replies View Related

Ubuntu :: Password Fields In Terminal Won't Accept Text?

Nov 24, 2010

It's a pretty weird issue I'm having, when I need to provide access for a command in terminal IE: something using sudo, it just doesn't accept text. I thought it might be my keyboard at first (g15) but I tried copying and pasting the password into there and it just wouldn't do anything except for remain blank

View 3 Replies View Related

Ubuntu :: Formatted Output To Terminal - Fields Need Updating

Jan 25, 2010

I'm writing a couple of programs in C and need to do something to formatting the output. I'm after producing something like a old mainframe screen or early micro where you could PRINT (x,y) to put something on the terminal where you want it. Learning GTK or such is not an option due to time constraints, and some fields need updating frequently during processing, so letting the terminal scroll is going to drive the operator up the wall pretty quickly.

View 2 Replies View Related

Software :: Top: Select The Shown Fields From The Command-line?

Feb 8, 2010

I want to select the fields which the 'top' command shows from the command-line. I can do that in the interactive mode when I press 'F', but I would love to do it via parameters (or with a configuration file, if it doesn't work otherwise).The fields I'd want to leave out are triggered by these letters: AHIOQTWMBackground:I installed the "compa" Gnome applet and want to always see what program currently uses up most ressources. For example, Pidgin sometimes starts using up 100% of 1 CPU and I have to kill it and start it again. I can already filter 1 or 2 programs from the 'top' command using the 'head' and 'tail' commands, but there are too many fields for my purposes by default. I could make a C program that filters those fields I need, but I think there must be a simpler solution.

View 2 Replies View Related

Ubuntu :: Insert Image Fields In Reports Using OpenOffice.org Base?

Jun 14, 2010

I tried to create a report from a table which contains text and image fields. The created report show text fields well but only empty fields as Images. How can I do that?

View 1 Replies View Related

Ubuntu :: Wine Crashed Now Can't Type In Txt Fields And Lost Max, Min, And X From All Windows

Oct 29, 2010

Using wine, re-installed EVE (hadn't played for awhile), things went fine, ran eve, things were fine... then like an idiot in the middle of the opening graphic sequence I tried to exit out... big mistake... system hung up and I had to do a hard restart. Upon restart the following has happened:

1. I currently cannot type into SOME text fields. I can type into Firefox, and Open office, but not into KDE wallet, Kubuntu search fields, or the terminal (big problem). If i go out of KDE and straight command line I can run terminal commands. I can also cut and paste into all text fields including the ones I cannot type into.

2. I've lost all X, Minimize, and Maximize from ALL windows, and cannot move windows. I can resize some windows, like firefox however. Windows are not layering properly, if any window is open the "start" button menu will be blocked out, and the opened windows will not layer behind it (makes me have to resize windows to shut down).

3. Tried to go back to a prior good configuration to no avail. The 3 most recent configs have the same errors now, and the configs prior to that are refusing to initialize KDE... screen will flicker and then go strait to command lines.

notes: I have tried changing graphics drivers to no avail, and have redone the keyboard selection to no avail. Also uninstalled wine, but that didn't do anything. basically, I can work within the errors and make stuff run, but it's a huge PITA. running Kubuntu 10.10*was running wine 1.3.5

View 1 Replies View Related

General :: Removing Specific Field Seperator To Combine Two Fields?

Dec 2, 2010

I am trying to remove the space between the 2nd and 3rd fields but just cannot work out how to do it. I've considered sed, cut, awk...I know with sed you can replace all instances within a file but can you also specify to remove, say, the 2nd instance of a space in each line (this would be perfect for me)?

DAAE 60 402 Bejaia Algeria 1 36-43N 005-04E 36-43N 005-04E 2 2 P
DAAG 60 390 Dar-El-Beida Algeria 1 36-43N 003-15E 36-43N 003-15E 25 25 P
DAAJ 60 670 Djanet Algeria 1 24-33N 009-28E 24-33N 009-28E 1054 1054 P

[code]...

View 3 Replies View Related

General :: Understand Cpu Family/model/stepping Fields In /proc/cpuinfo?

Feb 26, 2011

I have following in cpuinfo:

processor : 0
vendor_id : AuthenticAMD
cpu family : 15

[code]....

View 2 Replies View Related

Programming :: How To Remove The Last Character

Jun 27, 2010

I have a string like this "/home/test/filename.txt" and i want to delete all character after the last "/". how to do that using sed or awk.

View 5 Replies View Related

Programming :: Remove All Lines Containing 'A,,,,,,?

Nov 3, 2010

How can I remove all lines which contain A,,,,,, I tried the following sed statements but no luck.

Code:

sed "/A,,,,,,/d file"
sed "/A,,,,,,/d file"

View 6 Replies View Related

Programming :: Remove First And Last Character?

Feb 24, 2010

which is the simplest way to have first and last character cropped out from a string? Something simpler than

Code:

echo $STRING | cut -b 2- | rev | cut -b 2- | rev

View 6 Replies View Related

Debian :: Change Font Size In Editable Fields - Borked After Fglrx Install

Sep 10, 2010

I recently installed an ATI graphics card driver (fglrx) and ran the aticonfig --initial program/option, which makes the necessary changes to xorg.conf for the user.

My original problem was that all of my font sizes were changed (far too small to even read). I found a temporary way around this by simply increasing the sizes in the gnome appearance properties, but the problem is there is no option to change the size of text that appears in editable fields. For example, simple text-line entry widgets in various applications appear very small (as well as the default text size in icedove mail). Trying to use openoffice.org Writer or Calc also gives the same results. It seems directly related to the sizes of "editable fields" (things like my text editor - gedit- appear to be fine, as well as my terminal). I'm guessing this could have something to do with my xorg.conf, but I've looked through the file and don't know what to change, or where else I could look. If it helps at all, I have most of my font sizes now (in gnome) set to 14, but they appear as 12.

I'm not sure exactly why this is happening, but I need some help in getting some of this text readable again. Please see the attached screenshot of a blank Calc spreadsheet, and it might shed some light on this. You might also notice that in the screenshot, the default font size is 10, but if I change this to 12, and then load it on say, a Windows computer, the text will appear to be much larger than a 12. I'll also include my xorg.conf, in case that has anything to do with it.

Code:

View 14 Replies View Related

Security :: Netfilter Hook - Kernel Module - Skb_transport_header - Tcphdr Fields Wrong Values

Apr 1, 2010

We are trying to implement a firewall as kernel module through netfilter hooking (in C). In the following code we are allowing only TCP traffic. Source port number and destination port number are printed for every TCP packet. On execution, this code prints wrong port numbers. This is the first time we are using skb_transport_header function for accessing tcp headers.

We verified port numbers being printed by firewall through NFS traffic. On the same machine where firewall is running, we hosted an NFS server. An NFS client (from a different system) puts a file in exported mount. Firewall is able to capture packets for this file transfer but port numbers printed are wrong. It prints '69' for source portnumber (whereas ethereal capture shows it as 790) and prints '553231' for destination port (whereas for nfs version 4 it has to be 2049).

[Code]....

View 1 Replies View Related







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