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
ADVERTISEMENT
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
View Related
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
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
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
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
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
Nov 27, 2010
How do I do this?The script below obviously dosn't work.
#!/bin/bash
for u in $(awk '{print $2}' user.txt)
for i in $(awk '{print $1}' user.txt)
[code]...
One text file with two columns in it, I need to iterate through the file and print the different columns each time
View 9 Replies
View Related
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
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
Aug 6, 2010
I am having a problem unzipping multiple files at 1 time.
Proper unzip command that will:
1) extract the file from the zip.
2) remove the zip file.
All my zip files start with SB and end with .emi.zip
SB*.emi.zip
View 2 Replies
View Related
Jun 15, 2011
I'm looking for a program that will digitally display the time in three different cities - all showing at once. I don't care if it is a panel applet or stand-alone. I'm using Suse 11.3 and Gnome.
View 5 Replies
View Related
Aug 8, 2010
I'm in Gnome but if I logout I can get to a menu where I can choose KDE as well as other window managers. The problem is I have a program that's running inside Gnome and I don't want to stop it. Is there some way I can get into KDE without having to stop this program?
View 3 Replies
View Related
Dec 4, 2010
So, I usually write/find a test case generator for any code that I write. This type of code generally leads to some file output. To be thorough, I try and generate many different files to test my code on.
Say the command is like this:
Is there a way to automate this for many different values of the parameters and generate many different files?
I tried:
I wasn't able to use the $i in the filename, and without it the command gave me no errors, but did nothing else either. I know the Unix command line is very powerful, and I have a feeling that this should be possible, but I just don't know how to do it.
View 3 Replies
View Related
Mar 29, 2010
I am trying to write a script which compares a log file with reference file. The log file has a table, the LHS of the table are constants strings and RHS of table values changes if there are any changes in configuration.code...
Here I am looking for a script which compares test.log file ( whose RHS data-types are known prior whether it is digit or string) with test.Ref which is reference file for test.log file. It will be really helpful for me if any of you give some idea about writing this script.
View 2 Replies
View Related
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
Jan 20, 2011
I have a text file with 2 columns. Column A has 69,000 rows. Column B has 49,000 rows. Column A has our complete product list Column B has product list from Manufacturer 1 There are only certain/some rows which are common between 2 columns. and also, column B is not a subset of column A. Column A has extra entries and so does column B. I need to know, which rows from Column B, are common with Column A which rows from Column B are not common with Column A. Essentially I want to know from this list, how many of our products are from my manufacturer 1, how many does my manufacturer has which we dont carry.
How would I acheive this? My natural approach to solving this kind of obstacle is to reach for MS excel and use its lookup function, but its not working... Its taking forever and hanging up. since the file is so huge and probably my excel skills are really bad.
How can I do this from command line? I am looking for awk command if possible instead of sed since I am trying to pick up its syntax and usage etc. My thought process is, sort column A,B, for every row in A, lookup and output based on condition. Dont know if I am on the right track.
View 7 Replies
View Related
Jul 29, 2011
I would like to transform rows into columns from a file in bash.
View 4 Replies
View Related
Jun 2, 2010
I'm pretty sure this is super simple, but I've searched and searched and for the life of me I can't find any info on how to limit the columns that display in the interactive top program with arguments passed from the command line. I recall seeing something formatted like this ...
~/top -f (kdx)
Which would only show the %CPU, UID, program name fields/columns. I'd like to display the results in a really narrow terminal window on the right side of my desktop.
View 5 Replies
View Related
Mar 20, 2011
I'M working my way through Trainsignal's CompTIA Linux + Training course and I have a question about IRQs. According to the lesson using the command "cat /proc/interrupts", I need to memorize the system IRQs number columns 0-15. But when I use this command, I get somewhat of an unordered list, see below.
Code: cat /proc/interrupts
CPU0 CPU1
0: 48 7 IO-APIC-edge timer
1: 247 205 IO-APIC-edge i8042
[Code]....
View 1 Replies
View Related
Mar 21, 2011
I have an ASCII file containing 3 Columns of descending data as flollows:
3277.233 | 9.032167E-16 | 5.354040E-16
3276.725 | 1.825813E-15 | 7.552098E-16
3276.211| 2.472245E-15 | 8.826818E-16
3275.699| 2.943001E-16 | 3.192112E-16
[Code]....
I want to sort them in ascending order.
Does anybody know how to do it in Ubuntu 10.4.
View 5 Replies
View Related
Jul 13, 2011
I am running the command on a Mac but due to it being a generic unix command and a command line query.. I thought I can write on this forum.. I am running the command
Code:
df -h | grep '/dev/'
I get
Code:
/dev/disk0s2 389Gi 62Gi 327Gi 16% /
/dev/disk0s3 76Gi 24Gi 52Gi 32% /Volumes/Backup
/dev/disk3s2 500Gi 47Gi 453Gi 10% /Volumes/Misc
Note the huge space between the 1st and 2nd Column..
This is because currently I have some NAS drives mounted which are not showing due to grep. When they are not mounted. The output is fine with equal spaces between each column (like between col 2 and 3.. or 3 and 4). I want to do a (dare I say) sed or awk or something to reduce the space between 1st and 2nd col. So that it has space like between col 3 and 4.. or 2 and 3. This is because I am showing this output somewhere and because of the space its not showing up correctly.Also I hope the command will still work when the NAS drives (afp) are not mounted.. basically consistency. The spaces are not showing properly in the quote tag. Changed it to CODE tag.
View 12 Replies
View Related
Sep 28, 2009
as a result of a find command, i have
852065 72: /bin/gunzip
852065 72: /bin/gzip
852065 72: /bin/zcat
(the first column is inode number and the second is size if you're curious)
I want to be able to format it in a way such that:
852065 72:
/bin/gunzip
/bin/gzip
/bin/zcat
I know I can get the bottom half using awk- but I can't figure out how to extract the first set of numbers and get them to appear only once
View 9 Replies
View Related
Mar 4, 2010
if there's a tab-delimited file under /usr/desktop, how can I determine the number of rows and columns of the file in shell?And, if told the the 3rd column of the file contains only numerical values and all values in the 5th column are unique, how can I verify these in shell?
View 13 Replies
View Related
Jun 24, 2010
Is there any way to run multiple instances of yum at the same time. The need is to speed up the install process.
View 2 Replies
View Related
Dec 4, 2010
I want to be able to use multiple options at the same time and some of those options will require an argument and some will not.
Here is my bash script:
#!/bin/bash
while getopts ":a:bc:de:fg:" opt ; do
case $opt in
a)
[Code]....
If I only use option -a with no arguments, the script works...
View 1 Replies
View Related
Jul 1, 2010
Is there any scanner that can scan multiple pages at a time? Without human intervention. Then put all the scanned pages in 1 tiff file or multiple gif or png or jpg files. A scanner that works with Linux. I need make and model.
View 1 Replies
View Related
Feb 21, 2011
How can i create multiple users at a time in rhel?
View 2 Replies
View Related
Jul 1, 2010
I want to create 2 cron jobs daily
1st cron: Every day by 13(1pm) I want to stop the httpd service
2nd cron: Every day by 13:30(1.30pm) I want to start the httpd service
I tried but only 1 cron job can able to run at a time.
View 7 Replies
View Related
Mar 10, 2010
I've worked out how to get ALSA libasound code working for an application. However I can't workout how to get multiple sounds working at once. I can't seem to find any google examples of mutiple sounds. EG tune plays while pressing buttons makes clicks. I'm using an embedded board so need to use ALSA not an addon e.g. sdlmixer, jack, etc.
View 3 Replies
View Related