General :: Extracting Columns From Multiple Files With Awk?

Sep 22, 2010

I'd like to extract a single column from 5 different files and put them gether in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is:awk 'NR==FNR{a[NR]=$2; next} {print a[FNR], $2}' file1 file2I added the file3, file4 and file5 at the end, but it doesn't work. Does anyone know what do I have to do?

View 5 Replies


ADVERTISEMENT

General :: Merge Columns From Multiple Files?

Dec 20, 2010

I want to merge columns (selectively) from several files and create a new file with the merge output. I saw some suggestions to use pr/paste to join the columns and then awk to pick-up the columns.

Code:
pr -m -t -s file1 file2 | gawk '{print $4,$5,$6,$1}'
But I have hundreds of files and I cannot manually pick up columns using awk as given in

[code]....

View 14 Replies View Related

Programming :: AWK (or TCL/TK): Matching Rows And Columns Between Multiple Files?

May 26, 2011

I've been hitting my head against a wall for awhile with this one:As the last part of some data analysis I performing I would to construct a matrix from a series of different files. These files have the format:

file 1 file 2 file 3
AAAAA .1 AAAAA .1 BBBBB .1
BBBBB .2 BBBBB .1 CCCCC .9

[code]...

View 6 Replies View Related

Programming :: Extracting Columns In Particular Order?

Jun 9, 2010

Say I have a text file with10 columns. I need to reorder them based on a list of column numbers that will reorder them.

My problem is this:

If I want to cut out 5 columns (columns 1,2,3,9,10) in the order 1,10,2,9,3 then I have tried using:

Code: cut -f1,10,2,9,3 my_file.txt > reordered_file.txt But this just extracts the columns in order as if I used:

Code: cut -f1,2,3,9,10 my_file.txt > reordered_file.txt How can I cut these columns and place them into the new file in the order I specify?

While this might seem quite trivial, I will actually need to do this for a file containing ~14000 columns with ~12000 columns that I need to extract in a particular order.

View 2 Replies View Related

General :: Cut Multiple Columns At A Time?

Aug 18, 2010

I am having a souce file (say SOURCEFILE) as below with 5 columns and many rows.

pol name status loan address
123 aaa 21 100 RJY
234 bbb 31 200 RMY
345 ccc 21 300 SJY
456 ddd 41 400 pqr

i want to compare the file (say COMPAREFILE ) which is below :

123
345

I need the following output file (sayOUTPUTFILE) as below :

( ie for file COMPAREFILE i need column 2, column 4 ie name and loan from source file )

ie output file required is to be like below :

123 aaa 100
345 ccc 400

Till now iam using the following method.

1. cutting column 2nd column
2. again cutting 4th column
3. in third, step merging the 2nd and 4 th column.

method of writting single line command or any awk programme to do this in one step.

I need output file (say OUTPUTFILE) as below

View 1 Replies View Related

General :: Bash Script To Read Csv File With Multiple Length Columns

Jul 27, 2011

I've searched everywhere and I can't come up with a good solution. For each line I need to find the average, min, and max. I've seen plenty of solutions where the number of columns is fixed, unfortunately for me these lines can get pretty large. My thought was to read each line individually into an array, loop through the array and find the avg, min, and max that way but i haven't had much luck. I can read each line using a while loop but I'm having trouble with the array part, or perhaps that's not the best solution?

View 14 Replies View Related

General :: Extracting Information From Multiple Text Documents?

Jul 7, 2010

I am an astronomy student using Ubunut 10.04, and a frequent user of IRAF ( an *nix image processing application geared toward astronomy). IRAF produces, amongst other things, a text document with various values on it (example below).

Code: K IRAF = NOAO/IRAFV2.14.1 version %-23s
#K USER = name %-23s
#K HOST = Balthazar computer %-23s
#K DATE = 2010-04-29 yyyy-mm-dd %-23s

[Code]...

Now, the information I'm actually interested is the X and Y coordinates down towards the bottom (in this case, 973.505, 271.474).

I have about 800 of these output text files, and I was wondering if there's any sort of script or command that could go through them (presumably reading from a list of file names), and extract the coordinates. Ideally, the output would be a list of coordinates (i.e. X-coordinate, Y-coordinate).

View 1 Replies View Related

General :: Merging Columns From Different Files?

Oct 10, 2010

I have three files with the following structure:

file1
1 2 3 4
5 6 7 8

[code]...

View 4 Replies View Related

General :: Extracting Rar Files In RedHat?

Apr 26, 2011

How to extract rar files in RedHat Linux?

View 8 Replies View Related

Ubuntu :: LaTeX Regarding Multiple Columns?

Dec 19, 2010

I was trying to do a school assignment in LaTeX. The assignment involves having the page split into three columns: the first column is for the quote, the second is for a reaction, and the third is for questions. These columns must be able to break in the middle of a row. I was trying to accomplish this using LaTeX.

First, I tried the longtable environment, but that would not allow me to pagebreak in the middle of a row. Then, I tried parcolumns, but for some reason, the second "row" had a huge space between the first two words. Does anyone know of an environment suitable for this kind of work?

View 4 Replies View Related

Programming :: AWK - Combining Multiple Columns?

Feb 23, 2010

I have a folder with only 24 files named <number>.dat (i.e. 4.dat, 6.dat and so on) where <number> is between 0 and 256. Each file has just two columns of data and nothing else.

I'm trying to combine all the second columns ($2) together. I've been fiddling around with getline and so far have

awk '{ getline ln < "6.dat" ; print ln" "$2 }' 4.dat

which takes file 4.dat and adds $2 from 6.dat, but I want a single command to take each $2 from every file and add them to (for example) 4.dat (having $1 from 4.dat is no problem). A command that takes every file in the folder and grabs $2 and places them in a common file would be ideal. Frankly I can work around if you combine both columns from every file.

View 5 Replies View Related

General :: Possible For Ex. Extracting Image / Modifying Files / Then Remaking Iso?

Sep 23, 2010

I don't know almost anything about it so I was thinking of asking this question from the experts.I recently downloaded the xPUD 0.9.2.I LOVE that OS!It's simple,fast and smart.I just would like to add some other programs to it somehow.Is that possible for ex. extracting the image,modifying files,then remaking the iso?(Talking in Windows7)I would like to add some programs like Wine and some games also.Please reply as soon as possible because the xpud site is down for bandwidth exceeded.

View 2 Replies View Related

Programming :: [Perl] Fail To Sort A File With 300,000 Lines By Multiple Columns?

Nov 10, 2009

Each line of the file I am sorting is in the following format:

<url> <month> <day>

For example:

[URL]

I wrote the following to sort:

Code:

#!/usr/bin/perl
$in = shift;
chomp($in);

[code]....

The script worked fine for my small testing files, but failed in my input file. The input file is 18MB and containing more than 300,000 lines. The output will contains some lines like that:

url_one 10 1
url_two 10 1
url_three 10 3
url_four 10 1

Is that because my file is too big for perl to handle ?

View 10 Replies View Related

Software :: Gnu Tar Creates Multiple Odd Directories With Numeric Names When Extracting?

Feb 4, 2010

I become to use tar with incremental feature for archiving data under ubuntu.But when I try to extract archive later under windows (using gnu tar also) it creates many directories like this:

<...>
11324447220
11324447221

[code]...

View 2 Replies View Related

General :: Rename Multiple Files In Multiple Directories/subdirectories Recursively?

Aug 23, 2010

I am to rename all the files within a directory (which contains multiple subdirectories) recursively without invalid characters.

I tried the coding posted above.

find . -type f -printf '%p
' | while read file; do
oldfile=$(basename "$file")
newfile=$(echo "$oldfile" | sed 's/[^A-Za-z0-9_.]/_/g')
if [ ! "$newfile" == "$oldfile" ]; then
echo mv "$file" "${file%$oldfile}$newfile"
code....

but I get an error on both of them stating "find: bad option -printf find: [-H | -L] path-list predicate-list"

View 9 Replies View Related

Applications :: Printing Support (line Numbers - Syntax Highlighting - Multiple Columns Per Page - Customizable Fonts And Sizes) Not Available

Jun 17, 2010

I've been looking though different editors for one that has good printing support. Ideally it should be able to print C++ code with line numbers, syntax highlighting, multiple columns per page, customizable fonts and sizes and a print preview feature so that I can make sure it looks right before sending it to the printer. It appears that notepad++ had at least some of these features, but it is not available on linux. The best I could do so far is to copy/paste the output of 'cat -n foo.cpp' into oowriter and format it into two colums. I don't get synax highlighting though and I have to manually replace tabs with a few spaces as well as some excessive leading spaces before the line numbering.

View 1 Replies View Related

Ubuntu :: Combine Columns In Text Files?

Feb 15, 2010

I have two files which I would like to combine. Each file has 2 columns.

File 1:
1 a
2 b

[code]...

View 2 Replies View Related

General :: Extracting A Bzip2 File Throws "Can't Guess Original Name" And Does Not Extract Separate Files

Dec 13, 2010

I made a bzip2 file by

bzip2 -c /home/os/picture1 > /home/os/Desktop/pic.image

bzip2 -c /home/os/picture2 >> /home/os/Desktop/pic.image

But now extracting pic.image by bzip2 -d /home/os/Desktop/pic.image returns

bzip2: Can't guess original name for pic.image -- using pic.image.out

And then it just creates one file pic.image.out.

How do I access picture1 and picture2 from pic.image?

View 2 Replies View Related

Programming :: Bash Script - Merge Files Comparing Columns

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

Fedora :: Extracting Rar. Files Using Unrar?

Jan 18, 2010

After having downloaded unrar, I find I can't actually use it to extract rar files. Whenever I use the command unrar e filename.rar, (obviously using the correct filename), I just get told there's no such file or directory.

View 3 Replies View Related

Fedora :: Extracting The Multipart .RAR Files?

Jul 18, 2011

I am using XFCE spin Fedora, so my default archiver is Xarchiver. I have downloaded a 2 part .RAR file, and when I used to use them in Windows, I would tell WinRAR to extract the first part, and then it would automatically start extracting part 2 if it was in the same directory. When I try to do the same in Xarchiver it tells me "An error occurred! Please check the 'Store archiver output' option to see it." I don't know what 'store archiver output' is or how to access it. What do I need to do to extract both components and successfully join them?

View 6 Replies View Related

Ubuntu :: Extracting Splitted Z Files ?

Jun 24, 2010

I have a bunch of split Z files and I want to extract them but I cannot find how. To be more specific I have a file named foo which is compressed into files foo.0Z, foo.1Z foo.2Z. I have tried uncompress but does not work I have tried gunzip,gzip etc but no result either. Even 7zip will not do the work.

View 4 Replies View Related

Red Hat / Fedora :: Extracting The Files Permissions?

Jun 13, 2010

I'm trying to extract all files permissions and write them in a text file in order to use regular expression(using python) and search for world writeable files

View 2 Replies View Related

Slackware :: Extracting Metadata From WAV Files?

Feb 6, 2011

Kernel 2.6.21.5, GNU/Linux (Slackware 12.0).

A tool to extract metadata from a WAV file and present it in human readable form?

View 4 Replies View Related

General :: Creating A Script To Move Or Copy Files Into Multiple Directories Below The Files?

Aug 25, 2009

How can you create a script to move or copy files from a main directory into multiple directories below the main directory.

View 7 Replies View Related

Ubuntu :: Clonezilla And Extracting Files From Windows?

Apr 22, 2011

I have a backup of a Windows OS done by Clonezilla but would like to know if its possible to extract the files from a Windows computer from the backup CD where the backup was saved . Can this be done and what software will be able to help.

View 2 Replies View Related

Red Hat / Fedora :: Extracting Files In Sub Directory Recursively

Feb 27, 2010

I am new in Linux and I need to extract alot of zipped files (different format (e.g tar.gz, tar.gz2)) which are in subdirs and I do not want to go to each subdir and extract each file because it will take alot of time. Is there away to extract all files that are existing in dirs and subdir with "for loop" or is there a script that can do the job automatically.

View 1 Replies View Related

Red Hat / Fedora :: Replace Newer Files When Extracting From Tar?

Jan 29, 2011

Oftentimes, I want to restore a directory from a tar.gz backup file.When I extract the backup tar.gz, is there a way to make it only replace newer files in t directory?Currently, I have only been able to achieve this bydeleting the entire target directory and extracting the entire backup file. This is timeonsuming because the backups are sometimes hundreds of gigabytes.

View 8 Replies View Related

Ubuntu Networking :: Extracting Files For Ndiswrap Failing

Feb 8, 2010

is that my ar928x atheros wireless connection is severely slow. To fix it I've heard ndiswrap and so I've downloaded the XP driver from HP's support site (a pavilion dv7-1450us Notebook PC) and met a brick wall. The file is sp45222.exe and it contains seemingly no .bin .inf or .sys files that ndiswrap dearly requires. I've tried extracting it on a windows machine with UniExtract. This gives only three files one of which UniExtract can extract into a compilation of folders none of which have the required files. I've also attempted to use cabextract on my Ubuntubox, but not cabs come out. I have unshield, if that's relevant at all. What on Earth am I doing wrong?

View 3 Replies View Related

Ubuntu :: Extracting TGZ Files - Exit With Failure Status

Jul 20, 2010

I am trying to extract a .tgz file. I have used the command tar - xvwzf filename.tar but I get the following error:
gzip: stdin: decompression OK, trailing garbage ignored
tar: Child returned status 2
tar: Exiting with failure status due to previous errors
root@test:/datastore/Newfolder# tar -xvwzf filename.tgz

View 9 Replies View Related







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