Sponsored Content
Full Discussion: Combining sed actions
Top Forums Shell Programming and Scripting Combining sed actions Post 302910813 by disedorgue on Monday 28th of July 2014 10:35:43 AM
Old 07-28-2014
Hi,
Another sed solution (general):
Code:
$ cat iid.txt
ID1
1       5
6       8
ID2
1       4
5       7
5       7
5       7

ID3
1       4
$ sed  -e ':yy;/^[A-Z]/{s/$/\t/;:xx;$bzz;N;s/\(\n\|\t\)\([0-9]\)/,\2/g;txx;};h;s/.*\n//;x;s/,//;s/\n.*//p;x;tyy;:zz;s/,//' iid.txt
ID1     1,5,6,8
ID2     1,4,5,7,5,7,5,7

ID3     1,4

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with simple scripting actions

Hi, I am a beginner in unix shell scripting. I wanted simple information like 1- How to know what are the number of command line options given for the script file? 2- How to check if a variable value is interger or string? 3- How to use awk to replace value of a variable For example I... (5 Replies)
Discussion started by: Nads
5 Replies

2. HP-UX

Auditing User's actions

Hi all I hope to find what i'm looking for in this forum as said in the topic i want to track user's actions on the system. i mean also the action of moving or removing files. I have an HP 9000 with HP UX 11i. the users log on the HP from a terminal window under WIndows XP Thx (3 Replies)
Discussion started by: Timberland
3 Replies

3. UNIX for Dummies Questions & Answers

combining sed commands

I would like to change the lines: originalline1 originalline2 to: originalline1new originalline1newline originalline2new originalline2newline To do this, id like to combine the commands: sed 's/^/&new/g' file > newfile1 and sed '/^/ a\\ newline\\ \\ (2 Replies)
Discussion started by: Dave724001
2 Replies

4. Shell Programming and Scripting

Sed: Combining Multiple Lines into one

Before I ask my actual question, is it going to be a problem that I want to run this process on a 15 Gig file that is ~140 million rows? What I'm trying to do: I have a file that looks like Color,Type,Count,Day Yellow,Full 5 Tuesday Green,Half 6 Wednesday Purple,Half 8 Tuesday ...... (3 Replies)
Discussion started by: goldfish
3 Replies

5. Shell Programming and Scripting

Need help on Mulitple files mutliple actions

Hi all, I have mistkanely gzipped twice an entire folder and sub folders, and also renamed the files during that process. I am trying to undo this, and I need help to create the batch to work on it. All folders are under my images directory, I have a output.txt file that holds all the... (1 Reply)
Discussion started by: saariko
1 Replies

6. Shell Programming and Scripting

combining awk and sed

Hi experts, I have a requirement, In which I need to display the first and last line of a zip file where the line starts with "L". I've writen the code like below using sed and awk. gunzip -c 20110203.1104.gz | awk '$1 ~ "^L" {print substr($0,178,15)}' | sed -n '1p;$p' Is it possible to do it... (8 Replies)
Discussion started by: senthil.ak
8 Replies

7. Shell Programming and Scripting

Combining multiple rows in single row based on certain condition using awk or sed

Hi, I'm using AIX(ksh shell). > cat temp.txt "a","b",0 "c",bc",0 "a1","b1",0 "cc","cb",1 "cc","b2",1 "bb","bc",2 I want the output as: "a","b","c","bc","a1","b1" "cc","cb","cc","b2" "bb","bc" I want to combine multiple lines into single line where third column is same. Is... (1 Reply)
Discussion started by: samuelray
1 Replies

8. Shell Programming and Scripting

combining multiple sed statements

I need to run a cronjob that will monitor a directory for files with a certain extension, when one appears I then need to run the below scripts How do I go about combining the following sed statements into one script? and also retain the original filename.? sed 's/71502FSC1206/\n&/g' # add a... (2 Replies)
Discussion started by: firefox2k2
2 Replies

9. UNIX for Beginners Questions & Answers

Help using combining variables with sed command (RHEL 7)

Here is the whole script, very simple, but I am just learning ROK_NO=$1 RPT=/tmp/test sed -E '/^SELECT/ s/(.{23}).{8}/\1'"$ROK_NO"' /' $RPT echo $RPT When I run this I get $ bash rok.sh 2388085 : No such file or directory /tmp/test When I type the command in console, it works... (3 Replies)
Discussion started by: isey78
3 Replies
GO-FILTER-SUBSET(1p)					User Contributed Perl Documentation				      GO-FILTER-SUBSET(1p)

NAME
go-filter-subset.pl - extracts a subgraph from an ontology file SYNOPSIS
go-filter-subset.pl -id GO:0003767 go.obo go-filter-subset.pl -id GO:0003767 -to png go.obo | xv - go-filter-subset.pl -filter_code 'sub{shift->name =~ /transcr/}' go.obo DESCRIPTION
Exports a subset of an ontology from a file. The subset can be based on a specified set of IDs, a preset "subset" filter in the ontology file (eg a GO "slim" or subset), or a user-defined filter. The subset can be exported in any format, including a graphical image ARGUMENTS
-id ID ID to use as leaf node in subgraph. All ancestors of this ID are included in the exported graph (unless -partial is set) Multiple IDs can be passed -id ID1 -id ID2 -id ID3 ....etc -subset SUBSET_ID Extracts a named subset from the ontology file. (only works with obo format files). For example, a specific GO slim ONLY terms belonging to the subset are exported - the -partial option is automatically set -namespace NAMESPACE only terms in this namespace -filter_code SUBROUTINE advanced option A subroutine with which the GO::Model::Term object is tested for inclusion in the subgraph (all ancestors are automatically included) You should have an understanding of the go-perl object model before using this option Example: go-filter-subset -filter_code 'sub {shift->namespace eq 'molecular_function'}' go.obo (the same things can be achieved with the -namespace option) -partial If this is set, then only terms that match the user query are included. Parentage is set to the next recursive parent node in the filter For example, with the -subset option: if X and Y belong to the subset, and Z does not, and X is_a Z is_a Y, then the exported graph withh have X is_a Y -use_cache If this switch is specified, then caching mode is turned on. With caching mode, the first time you parse a file, then an additional file will be exported in a special format that is fast to parse. This file will have the same filename as the original file, except it will have the ".cache" suffix. The next time you parse the file, this program will automatically check for the existence of the ".cache" file. If it exists, and is more recent than the file you specified, this is parsed instead. If it does not exist, it is rebuilt. DOCUMENTATION <http://www.godatabase.org/dev> perl v5.14.2 2010-05-12 GO-FILTER-SUBSET(1p)
All times are GMT -4. The time now is 01:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy