Ubuntu :: Parse Line With Colon Field Separation?
Jan 16, 2011Source:
Code:
JAMES ::: AAAA ::: 1111
JANET ::: BBBB ::: 2222
LAURA ::: CCCC ::: 3333
[Code].....
Is there a way to do this from command line?
Source:
Code:
JAMES ::: AAAA ::: 1111
JANET ::: BBBB ::: 2222
LAURA ::: CCCC ::: 3333
[Code].....
Is there a way to do this from command line?
I need to have a shell script which does the following,
1. Remove '/' in the file
2. Replace ';' with new line
Input file (sample):
TL/01039;TL/07014;TL/07016;TL/07046;TL/09476;TL/09522
Output file should be:
I've written a script to parse a file and print each line that ends with matching pattern, if the next line is blank. The pattern lines are the result of md5sum $i|sed 's/path///g' so that only md5 and filename appear. Here's what I'm using.
Quote:
for fline in `sed -n '/.*.ext$/p' file1`
do
if [ "`sed -n -e '/'"$fline"'/ {n; p;}' file1`" == "" ]
then
echo ""$fline" has no info" >>file2
fi
done
[Code]....
I am trying to parse command line arg using getopt().this is my code
int main(int argc, char** argv)
{
int a=0,b=0;
[code]....
myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory
Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?
I have a pipe delimited flat file, field 27 is price. I would like to move items marked sold to a new file every couple months.
awk -F"|" '$27 == "SOLD" {print $0}' awktest2.data >> awkout2.data
Allows me to write line to new file but I need to delete the original line, I also want to make sold case insensitive tried [Ss][Oo] with no luck
I am trying to parse a line from a file and place the values into separate variables:
input.txt:
Code:
CreateVegaFeed-20110928-before-skip-start
this is the code i have done so far:
Code:
$input_file="input.txt"
INPUT_FILE=`cat $input_file`
for i in $INPUT_FILE
[Code].....
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.
I've just upgraded to 11.3, as a result, the suse-supplied video driver runs very slowly (screen-saver updates about 2 fps, to give you an idea) On 11.2, I had installed nvidia's native driver and things were just fine, so I tried to install the latest nvidia driver again, but I'm getting a hard hang with Yast -- at 99% downloaded, yast stops responding ("abort" doesn't respond, but an external "kill" signal works)
Finally getting the bright idea of checking the y2log file, I see the following code...
these three lines are repeated every second
I'm sure there are some fingers to be pointed [nvidia's ftp server is borked; aria2c is clueless, etc] but that does not help me - what do I need to do to convince this "aria2c" program that the file has, in fact, completely downloaded so that the installation process can continue?
I've had a very colorful morning learning the innerparts of Linux's sort command, and have come across yet another issue that I can't seem to find an answer for in the documentation. I'm currently using -t, to indicate that my fields are split by the comma character, but I'm finding that in some of my files, the comma is used (between double-quotes) within values:
Jonathan Sampson,,foo@bar.com,0987654321
"Foobar CEO,","CEO,",ceo@foobar.com,,
How can I use a comma to terminate my fields, but ignore the occurences of it within values? Is this fairly simple, or do I need to re-export all of my data using a more-foreign field-terminator? (Unfortunately, I do not have any control over declaring a different terminator with this particular project).
I'm trying to display fields from flat files where the first 8 fields are always the same. Fields 9 - n are varied but will contain specific patterns I'm after. I'm using this so far because "mySearch" is on each line I want to examine.
Code:
How would you pattern match and include 2 additional fields above field $9 but change field position from line to line?
I get this error message: E: Malformed line 57 in source list /etc/apt/sources.list (dist parse)
I am pretty new to Ubuntu and dont really understand computer
Here is the sources list (??) as well
This will probably be a simple question for the experts here, but I've been googling and testing and trying for a few hours with no luck. I'm tired and stumped. My simple test case:
Code:
$ cat test.txt
First colon: Get everything after: first colon.I want to return all the text after the first colon. So that would be "Get everything after: first colon." This is what I currently have:
Code:
$ sed 's/.*: //' test.txt
first colon.This returns everything after the second colon.
How can print the, let's say 5nd field to the last field of every record (let's say we have 10 fields)?
I mean: I cant avoid to have to do:
print '{$5 $6 $7 $8 $9 $10}'
I am creating a game with random variables. In the game I have created a dialogue exchange to players. I have set up a table with various returns and I inserted {$fields} to represent various random variables. When I call on the requested fields, I only see the field text and my field names. Am I supposed to parse something and call it back another way?
ie: myfield is: "You have won {$random1} silver! <br />{$wi['gender'] majesty rewards you well." the code I am using to call that field is:
When I tried to upgrade my xubuntu 10.04 , I got this error
dpkg: parse error, in file '/var/lib/dpkg/available' near line 2 package 'x11proto-core-dev': value for `status' field not allowed in this context E: Sub-process /usr/bin/dpkg returned an error code (2)
i have a file : file.dat with following data
Code:
STORAGE PERCENTAGE FLAG:
/storage_01 64% 0
/storage_02 17% 1
/storage_03 10% 0
/storage_04 50% 1
I need to get the value of PERCENTAGE in a variable for a value of storage passed as variable i have tried the following without success like :
Code:
percentage='awk -vx="$defaultStorage" '{FS=OFS=" "}$1==x{print $2}1' file.dat
- 160gb is where i install CentOS (pretty much the hard drive for operation system) - Lets call this drive A
- Two 1TB drives run in RAID 1, using software RAID (this is where i will store personal data, pictures, movies, music, etc...) - Lets call this RAID 1 setup drive B
I am planning to run a virtual Win Server 2008 using Xen and have that be my domain controller. I will use samba to share drive B and have the network drive map when user login to the domain.
- If for some reasons i have to reinstall CentOS, this pretty much mean drive A will be formatted and reinstalled. Knowing my self i probably will goof up some config in CentOS and will need to reinstall the OS to fix it. Since drive B will be the centralize location for my home network, i dont want to lose the data. Will i be able to re-setup the RAID setup of drive B and still have all the data stored on it intact after a reinstall?
- Is the separation of OS drive and data drive recommended?
- Are there any better way to accomplish my setup? I am pretty much just looking to make a linux file server and windows on client's end.
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:
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 RelatedI'm using arp -a to get the mac address of the router I am connected to. This is the first line of the output:
Code:
? (153.106.80.1) at 0:50:3e:97:dc:a on en1 ifscope [ethernet]
I want to grab the mac address from this. I know that I probably need to use sed with a regular expression like [0-9A-F]+: but I am not sure how to do this.
Set ID3 genre field to podcast?
View 2 Replies View RelatedI use Ubuntu 10.04 and OpenOffice 3.2.We have forms we use for computers we sell. I have to fill out a profile. The problem is I cannot enter text into the text entry fields. I get this error:"Readonly content cannot be changed. No modifications will be accepted."Here is a link to one of the files. If you try to enter more that a digit or two in a text field, you get that error:[URL]
View 9 Replies View Related"Once upon a time", I think heard of a way to use variables in the url field in firefox(or maybe it was ubuntu in general?).Anyways, if one would type, for instance, "google pokemon," the url would be changed to
View 2 Replies View RelatedI'm building a symbol table and syntax tree using lex and yacc for a compiler.
I am stuck with an error for too long. I have defined two structures (one for Symbol Table and another for Syntax Tree).
Code:
typedef struct symbolTable{
char name[30];
.....
struct symbolTable *next;
[Code]......
here's the error:
bottomup.y:76: error: field 'info' has incomplete type.
I tried to define the structure definitions in a separate header file and included in .y file but it didn't work out.
I'm trying to get this done ASAP.
really only have played around with it off and on. I just installed a new login theme usimg Slim (the Fingerprints theme) and now whenever I restart the virtual machine (using VMware player) it will let me type in my user name but it doesnt show my cursor and wont let me tab down to my password field so I cant get in and change it back to a different theme. Is there any way that I can fix this or will I need to reinstall the whole thing?
View 1 Replies View RelatedI 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:
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.
The input file consists of several fields. The first field is always five or more characters long. I want to keep the last five characters of the first field.
Example:
If the input file record is FEDERAL PACIFIC ELECTRIC PRODUCTS then I want to keep DERAL I can do this in four steps by using C, REV, C, and REV again but that seems like doing an easy thing the hard way. Is there a straightforward way to achieve this result with C or some other command?
Why do you have to press ctrl-L to use the location text box in Nautilus? There used to be a setting in preferences where you could have it always use the text bar. Now you have to use some gconf command in the terminal. The gconf command I've used also will only work for normal users. If I want to open a root nautilus terminal to move files around between my mounted drives then I have to hit ctrl-l every time. It is really annoying because if I am in a Nautilus window there are lots of times where I need to copy the path to something I am doing in the terminal.
Why does it seem like everything involved with Ubuntu is simplifying things at the expense of having options? I thought GNU/Linux was all about options. I guess it still is, but I just cannot understand why you would completely remove options instead of just putting them in an advanced section or something.