Programming :: Std - List - Copy - Sort And Merge ?
Jun 24, 2011
I had a data structure like this:
I sort the list like this:
I think the logic is correct, maybe just some details.
Now my question is
1) Can I simply merge node1 and 2 without sorting? Like node_list1.merge(node_list2);
2) If not, how can I copy list1 and 2 into list3?
View 1 Replies
ADVERTISEMENT
Feb 17, 2011
Please I want Know the code of the Merge Sort with threads in C
View 7 Replies
View Related
Apr 8, 2010
I'm sure I'm not the first to have encountered a problem with synaptic when I tried to load it up to install a new bit of software (in this instance help screens for OO).However when I did I got the following error message E: Encountered a section with no Package: headerE: Problem withMergeListvar/lib/apt/lists/mirror.ox.ac.uk_sites_archive.ubuntu.com_ubuntu_di sts_jaunty_restricted_binary-i386_PackagesE: The package lists or status file could not be parsed or opened.E: _cache->open() failed, please report.
When I opened the file that had the apparent prolem < var/lib/apt/lists/mirror.ox.ac.uk_sites_archive.ubuntu.com_ubuntu_dists_jaunty_restricted_binary-i386_Packages > it transpired it actually contained the html page for the router ?? which seemed wierd to me.However I have recently I changed to a new ISPSo after a bit of a search, nothing explicity had my problem, and I was a bit stumped. Then I suddenly had a thought, after reading someone else how did something similar.... I then did the following....
Code:
sudo mv /var/lib/apt/lists/mirror.ox.ac.uk_sites_archive.ubuntu.com_ubuntu_dists_jaunty_restricted
[code]....
View 2 Replies
View Related
Nov 23, 2010
I'm running 10.10. I'm trying to generate a set of labels for a new contacts list in evolution. Problem is I can't get glabels to merge the new contact list, even though it is selected as default in evolution. When I select Objects, Merge properties, and format "data from default evolution addressbook", it always imports the contacts list which was the original default, even though I have changed the default. I have reinstalled glabels, but problem remains. Seems like a simple issue, but its driving me mad.
View 1 Replies
View Related
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
Feb 28, 2010
What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?
View 2 Replies
View Related
Feb 22, 2011
I am using ffmpeg for merge wav files to a mov video. My doing is below
1. First extract audio (wav file) from video
2. Create wav file from mp3 track 1
3. Create wav file from mp3 track 2
4 Merge extract audio from video with track 1 and track2.
Now finally create a new video with original video's video stream and merged audio stream.
Process is working. However final video is 3-4 times greater than original one. I want that final video should be near about size of original video. As I understand, all three wav files (created from ) make video larger.
Example commands i using is as below:
View 6 Replies
View Related
May 4, 2010
We switched from unix to linux and we have an old report that extracted data from a database, output to an ascii file and then sorted the results in the file based on different arguments. The report now blows up when it runs,and I can only guess it is because the options for sort on linux differ slightly from unix.For example, here is one of the commands issued from within the report app that ran on the old unix box:
if sort-sequence = "descending" then
'sort -t~" -f +3.0f -4.0 +5.0r -6.0 -f '
else
'sort -t~" +3.0f -4.0 +1.0f -2.0 -f'
I will eventually rewrite the report to store the data in a local table, but I can simply adjust the options to suit the requirments of linux. Basically, I need to know if this can be a quick fix for the short term.
View 2 Replies
View Related
Mar 29, 2010
I have a script generating some containing multiple lines. But I want to merge all lines using comma separated.
View 6 Replies
View Related
Apr 15, 2011
What is the best way to merge lines, in sed, awk or perl, that occur between certain strings? I'm new to sed scripting and I have been working on this for some time now. I have a large file (sample below) that I need to edit.
What I need looks something like this.
I'm working with a very large file so simply merging all the lines then adding a new line character before ">contig" and after "translated" won't work, at least not with sed.
View 5 Replies
View Related
Apr 13, 2011
I have 2 very long files which are quite similar:
file1.csv:
Code:
file2.csv:
Code:
I need this output:
Code:
explanation:
If the fields 3 (serie) and 4 (modello) are identical, the lines of the 2 files should be "added":
Code:
If the fields 3 (serie) and 4 (modello) are different, just print the line of both files:
Code:
Is there a way to do this without reading the (huge) files with a "while read line" loop?
View 14 Replies
View Related
Apr 1, 2010
I opened Braser, clicked Copy Disc... I'm trying to copy my CD to an ISO file on my Desktop. Instead, it says this
Code:
The image could not be created at the specified location. Do you want to specify another location for this session or retry with the current location?
You do not have the required permissions to use this drive.
View 7 Replies
View Related
Apr 28, 2011
I can't anymore sort GNOME Panel's window list by drag-and-dropping.Can I reactivate that? Is there another way to sort windows
View 1 Replies
View Related
Feb 2, 2010
How would I list 4 users ID numbered 10, 11, 12 and 13 from my users list and output them to a file busers where their names are numbered by ascending order? How would I accomplish that on a one line command?
View 4 Replies
View Related
Sep 11, 2010
I have hard drive with several thousand photos. These photos are in different formats, some are tif some jpg some raw (cr2). These files are in dozens of directories. What I want to do is produce a list of all the files, in all of the directories, sorted by the file name (not sorting on the path), listing the location, file name, size and date created.
For instance I may have a file called photo1.jpg in /photos/pics/
I may also have a file called photo1.cr2 in /photos/misc/ and a file called photo1.tif in /photos/processed/summer/.
I would like a text file that would look like this:
/photos/misc/photo1.cr2 2536658 2010-07-09 13:17
/photos/pics/photo1.jpg 320046 2010-07-07 14:47
/photos/processed/summer/photo1.tif 234456689 2010-07-10 09:22
Of course I want it to do this for all of the photos. I pretty sure that there is a way to do this with a minimum amount of work. I have no problem with using the command line.
View 3 Replies
View Related
Feb 10, 2009
I am trying to get this script to work. The purpose is to download a list of modules from the slax.org the list consist of a list of module numbers. What I am trying to do is Download the file or the file name corresponding to the number in the list.the list is comma delimited. this is what I have done so far and I am a stand still.
#!/bin/sh
# Wget script to retrieve modules from slax.org modules
#
# ----Begin of user defined values -----
# Path to wget
[code].....
View 7 Replies
View Related
Dec 2, 2010
I recently got a new desktop, and did a fresh install of Ubuntu 9.04 Jaunty Jackalope. The reason I installed 9.04 is because the laptop I have been on for the last 7 years or so suddenly stopped operating with grub updates. I would t urn the computer on and it would never get past the 'grub loading' screen. but thats a whole different story. So I did a fresh install of 9.04 off of a startup disc I made a while back. Then I copied my /home file from my laptop (the old one) and inserted it into the new desktop's /home directory. Worked like a charm (more or less), and all my settings were transferred to my new computer. Desktop, Preferences, Admin stuff, I can't find a problem with it. Now for the applications.
I've tried multiple how-to's but none of them have worked. I found one that told me to do the following in terminal. Keep in mind, although I've been running Ubuntu for about three or four years now, I would still consider myself a noob. Anyway:
sudo dpkg --get-packages <filename><destination>
this left me with a text only file called 'package.selections' I was then to copy this file into the home folder on the new computer and run the following:
sudo dpkg --set-selections <directory>
Up until that last command, everything worked just fine. The list had tons of package titles (none with a .deb or anything though) and their state, got it on to the new computer and ran the code only to get the following error:
dpkg --set-selections does not take any argument
So i ran it without the directory, and it gave me a new line. So I typed in the directory and it gave me the following:
dpkg: unexpected end in package name at line 1
I've tried numerous other commands changing up the syntax as I go, but haven't gotten any farther. My goal is to have all the same applications installed on my new rig without having to go and install all the packages one by one.
View 4 Replies
View Related
Jun 7, 2011
i have a Centos 5.5 server that some staff have installed some extra packages on. I'm in the process of building a 5.6 server and want to include the packages / updates from the previous server. Can this be done easily? Was thinking of listing everything in a text file then using yum install to populate anything that the old server has that the new one doesnt?
View 3 Replies
View Related
Dec 6, 2010
I'm writing a bash script to copy a list of files and do some stuff to them. Basically, I have the code written that does what it needs to do, but I can't quite understand why it works. I was hoping someone could clear up my understanding a bit.
Code:
The first line generates a list of files. I wrap each line in quotes because they usually have spaces in the directory names.
The second line changes IFS, and I understand what IFS itself does. What I don't quite get is what the separator becomes with that echo statement. If I'm reading that correctly, the backspace will remove the newline and essentially the result is nothing? I found this solution on a web page somewhere, but it was years old and there was no real explanation.
View 1 Replies
View Related
Jul 6, 2010
I'm a bit new to Python programming and hoped that someone might be able to help with a problem I'm having. What I essentially want to do is to combine two text files line for line. I know how to do this in a bash script so to give you a better idea here's the code for that:
Code:
This is basically for adding on values to the end of a CSV file that uses ';' as the delimiter. So say file1 said:
And file2 said:
Then running this command would create merged_file1_and_file2 which would be:
The code I'm using at the moment is:
Code:
As I'm sure any experienced python programmer will see, this prints out the first line of the file "csvraw" and then all of the lines of "stamps" and then the remainder of "csvraw".
What I'd like to do is something like: (pseudo code, I know it's not python ;-))
Code:
Is this possible? I've tried googling and my Python Pocket Reference hasn't been much help. I've looked at pickling but that doesn't seem appropriate.
View 1 Replies
View Related
Apr 19, 2010
Just i want to ask doubts in c programming. I dont know whether this is the right place to ask doubts in c. If this is not a correct place, may i know where can i get help for c programming?is there any active forum or mailing list for c programming?
View 6 Replies
View Related
Feb 27, 2011
I'm learning GTK , and would like to use Codeblocks, and/or KDEvelop, and compile my c files using that, but always get an error about gtk/gtk.h not found, but can't figure out how to add the commands... I normally type gcc -o Program1 main.c `pkg-config --libs --cflags gtk+-2.0` That's a lot to type every time to compile.. Isn't there an easier way, in KDevelop, Monodevelop, and/or Codeblocks to make this step quicker, by adding some sort of I-/usr/include commands, or something?? thanks in advance, =). I looked online for some results, but didn't come across anything handy..
View 1 Replies
View Related
Aug 25, 2010
I am executing the script.
with help of cron job but it is not executing in cron job.
i check owner and chmod and create the file and execute manually it is working fine but in cron job i set below
Crontab -e
8 14 * * * /home/tplinux/webapp/tpadminhost/collect_ejxml/ejrename.sh
wq!
after that wait till that time but script is giving message no such file in directory but same thing is excute manually it is running fine and found the files.
Below is my script details
file name ejrename.sh. code...
View 3 Replies
View Related
Jan 27, 2010
I have program like this:
Code:
with 'gcc -g' it runs well, but with 'gcc -g -O3' (with -O2 too) it crash.
output is something like this:
Code:
and gdb says
Code:
Why it try to compare something at address 0x209 when this address is not in the vector?
View 1 Replies
View Related
May 5, 2010
i have text file that filename contain the date of creation (i.e 2010.05.02.log).I would like to create a script that:-Ask for start date -Ask for end date- Concatenate all file on the requested period by date order.
View 1 Replies
View Related
Apr 4, 2010
I am trying to get the title of all the windows that i open,but cant make it right... code...
the problem is,that it will write the current windows many times,until i open another window,and so on.
View 1 Replies
View Related
Dec 1, 2010
I have a hash of hashes and I need to sort this by value and write to a javascript array file..Currently I am using the following
foreach my $key(sort { keys %{$trans{$a}} <=> keys %{$trans{$b}}} keys %transmission)
{
foreach my $role(sort {$trans{$key}{$a} cmp $trans{$key}{$b}} keys %{$trans{$key}})
[code]...
View 2 Replies
View Related
May 5, 2010
I am trying to import variable values from a profile file to a perl program.
I am using the below command for doing it.
Quote:
system (". /opt/bbfb/bin/setbbfbenv $codeset");
the above command does make variable values available to the running perl program..
Can some one help me on this front..
View 1 Replies
View Related
Apr 30, 2010
I have a multi-dimensional array like so:
Code:
Array (
[0] => Array (
[0] => Eleven
[1] => NumberEleven
[2] => 11 )
[1] => Array (
[0] => Twelve
[1] => NumberTwelve
[2] => 12 )
[2] => Array (
[0] => AnotherEleven
[1] => Eleven,Again
[2] => 11 )
I need to sort it by array[ $key ][ 2 ] so that it is sorted like so:
Code:
Array (
[0] => Array (
[0] => Eleven
[1] => NumberEleven
[2] => 11 )
[1] => Array (
[0] => AnotherEleven
[1] => Eleven,Again
[2] => 11 )
[2] => Array (
[0] => Twelve
[1] => NumberTwelve
[2] => 12 )
I've looked at the php array docs the closet thing I found was array_multisort which won't work for my above requirements, does anyone have any insight to how to sort this way?
View 3 Replies
View Related
Mar 10, 2009
Using PHP 5.x. I would like to sort a set of values first numerically, then alphabetically. For example, here's my code so far:
Code:
<?php
print "<p style="font-family:verdana;font-size:10pt">
";
$myArray = array("1223:starfruit", "34112:oranges", "1223:zucchini", "321:apples", "34112:pears", "1223:tomatoes");
[code]....
I have fiddled with array_multisort but I can't seem to get my head around it or the many sort routines in PHP.
View 3 Replies
View Related