Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

1
vote
1answer
26 views

Merging rows with common values

I am trying to combine pairwise matches in a text file so that i can find all matches in a group: e.g. my file contains two tab separated columns like this: Simon John Simon Paul Steve Simon Graham ...
2
votes
0answers
10 views

How to find out which process keeps tunnel interface(tun) up?

If I create a tun interface with ip tuntap add mode tun command and force it administratively up with ip link set dev tun1 up command, then the interface itself is always "physically" down: ...
1
vote
3answers
49 views

How to copy lines from multiple files into one new file and keep file name?

I have 81 files in .fasta format that contain (up to) 53 items. Such as: /User/MyData/Sample_1.fasta /User/MyData/Sample_2.fasta .... /User/MyData/Sample_81.fasta Each .fasta file contains a name ...
1
vote
1answer
35 views

Reinterpret terminal output

I have a program that executes some commands in a terminal (for example apt-get update) and stores the output. How can I reinterpret the output, so I can remove all information that is not needed ? ...
-2
votes
0answers
36 views

Longest/shortest Username in linux

I'm trying to configure a script that displays all the users on the computer, the groups they belong to, and the shortest/longest usernames. I have the first part set up with the users and groups but ...
0
votes
1answer
69 views

need help merging two Unix files

I have 2 pipe delimited files say file1 and file2. Where file1 has say 33 columns and file2 may have 34/35/36 columns. So let's not consider how mant columns we have. What I want to do is compare the ...
0
votes
1answer
49 views

make a table output

if it possible to do a snmpwalk in a perl script and put the output in a table to make a sort of association like for each hostname i have in the same line if index and desc i have the script in bash ...
4
votes
3answers
100 views

Redirect the tail output to a file then stop when match found

there is this log file that data coming in is continuous. what i wanted to happen is to tail -f this log file then redirect it to a file with the ff conditions example of the log files content ...
0
votes
1answer
64 views

Run script on multiple hosts [duplicate]

I have below script which creates user list and also filters ignore.txt file to ignore matching usernames. I would like to run this script on multiple hosts like hostA, hostB, hostC. Like if I run on ...
0
votes
2answers
62 views

put data in columns

I am trying to put this output in columns can anyone help? Routeur 2 ==> 89.89.156.112 If_Name :vRtrIfName.1.1 :vRtrIfName.1.2 Routeur 2 ==> 89.89.156.112 If_index 546 789 Routeur 2 ==> ...
0
votes
1answer
40 views

Add the number in the column if exists

I need to count Nodes_Util for each Queue. In the example below, queue1 has only one line, but it varies and it could be nothing sometimes and it applies to all queues. I want to dynamically add the ...
1
vote
6answers
67 views

Count the number of 0 and 1 in a file [duplicate]

I have a file (see below), and I would like to count the number of 1's and of 0's: 1 1 1 0 0 1 1 0 0 0 ... I tried to use awk but it doesn't work, for example, to count the number of 1's: awk -F ...
2
votes
2answers
102 views

How to compare strings in two files

I have two text files, one file contains entries such as Id Value 1 apple 2 orange 3 mango 4 banana 5 strawberry 6 papaya In other ...
1
vote
1answer
36 views

In-place substitution for paste command [duplicate]

When I run the following code echo '1' > file.txt echo '2' | paste file.txt - > file.txt I would expect the content of file.txt be 1 2, because the paste command as it name suggests should ...
4
votes
2answers
93 views

how to sort by the day of the week?

I have two files. file1: Dave 734.838.9800 Bob 313.123.4567 Carol 248.344.5576 Mary 313.449.1390 Ted 248.496.2204 Alice 616.556.4458 file2: Bob Tuesday Carol Monday Ted Sunday ...
1
vote
1answer
72 views

How to merge two files in the same row?

I have two files. file1: Dave 734.838.9800 Bob 313.123.4567 Carol 248.344.5576 Mary 313.449.1390 Ted 248.496.2204 Alice 616.556.4458 file2: Bob Tuesday Carol Monday Ted Sunday ...
3
votes
1answer
14 views

Find repository names from gitolite info output

How do I extract the names from the gitolite info command output, for further piping into a script? I'm writing a migration script to migrate all my repositories from gitolite to a Gitlab server. ...
2
votes
2answers
58 views

Need to obtain Awk output in specific sequence

Data in file: 1234567-5678907 3456789-1234563 3456789-1234567 . . . . n Now I want the output in the below format: 1234567-5678907,3456789-1234563,3456789-1234563....n I have used below command ...
2
votes
1answer
38 views

ksh/bash Formatting Files through sed by cat file|sed command

I am new to unix platform, (Alternate Approaches can be discussed) I am trying to change the colors of content of a file conditionally. My file is: A B C D Value Value Value Value Value ...
1
vote
2answers
27 views

How to merge the lines in Unix (Sun Solaris) in a specific pattern

I have below n number of lines in a flat file: uk,1234560000 uk,6789067000 uk,4567890000 . . . n lines Now I have to make it in below format: ...
1
vote
1answer
38 views

If statement in shell-script only half-working

I've been trying to write a script to rotate my monitor, I'll then assign it to a keyboard key. I've been fairly successful in making it rotate once, however when I run the script again, it doesn't ...
1
vote
1answer
44 views

Cut some fields from a text file to another

I have the following command: grep -owf champs.txt t.txt and I want to cut the result of this command from the file t.txt to another file. I know that it can be achieved by a nested command but I ...
3
votes
2answers
101 views

sed: inserting text before end of <HEAD> section

I need to insert some text into an HTML file before the end of the HEAD section. I'm trying: sed -i "s#</head>#<style> @page { prince-shrink-to-fit: auto } ...
2
votes
3answers
196 views

How to find a specific 'string' and print out the whole line?

I have a file named myfile.csv containing the following: abc:123:myname:1231 def:423324:arbitrary:value:string StackExchange:Unix:Linux From the terminal I run ./myscript.sh def The contents of ...
1
vote
4answers
111 views

matching and merging lines with awk & printing with Solaris

I want to merge the matching pattern with awk on a Solaris system. $ luxadm probe No Network Array enclosures found in /dev/es Found Fibre Channel device(s): Node WWN:2000000c50f1c8da Device ...
-3
votes
2answers
53 views

match two files and filter out [duplicate]

I have two files file A >TCONS_00000075 gene=XLOC_000030 CCGCCGGCTGCTGCGCGCACCGACTTGTCACCACCCCAGCACGTCCTCCACGTATACAAGCGCTACGGTC ...
14
votes
9answers
486 views

Filter or pipe certain sections of a file

I have an input file with some sections the are demarcated with start and end tags, for example: line A line B @@inline-code-start line X line Y line Z @@inline-code-end line C line D I want to ...
0
votes
5answers
119 views

Read File word by word

My problem is to read a text file word by word and recovers every word in a variable. I tried to do: while read ligne; do { for ( i=1; i<= length ($ligne); i++); do { var=$(awk '{print $i}' ...
0
votes
5answers
175 views

grep to fetch whole line

I have a file like: Chr1 Cufflinks exon 7136 7944 . + . gene_id "XLOC_000001"; transcript_id "TCONS_00000003"; exon_number "5"; gene_name "LOC_Os01g01010"; oId ...
0
votes
0answers
25 views

seeking hints for correct escaping of sed commands WITHIN yaml

I am having a hard time finding the issue why following lines of "code" break my cloud-init config. Basically I am calling a son object as part of the DigitalOcean API which has a yam format - I got ...
1
vote
2answers
51 views

How to obtain a plain (raw) binary dump of any file in Unix/Linux?

I have read many similar question on the Stack Exchange community but none of them address a 'clean' binary dump. I have used: xxd and sed combinations to try to obtain a clean binary dump from any ...
2
votes
0answers
63 views

Bash regular expression comparison fail for hex byte \x01

Bash regular expression fails to compare correctly for $'\x01' when End-Of-String char $ is used. All other byte values (seem to) compare correctly. Using GNU bash 4.1.5(1). Is this a bug, or is ...
0
votes
3answers
92 views

Remove special characters in a text file

I have a text file which contains in each line a sql query. For each line, I need to remove some special characters. Expl: if I have: select * from Users; insert into Users values ...
2
votes
4answers
83 views

Why isn't this awk command doing a full outer join?

Objective: Merge the contents of two files using common key present in the files file1.txt ========= key1 11 key2 12 key3 13 file2.txt ========= key2 22 key3 23 key4 24 key5 ...
2
votes
4answers
201 views

How to 'drop' characters from in front of a string?

I have a string that I would like to manipulate. The string is H08W2345678 how would I be able to manipulate it so the output is just W2345678? Similarly if the I wanted to drop the last 4 ...
0
votes
2answers
34 views

How to scrape multiple IP's and add in a script as a variable?

I am trying to add in my script an awk statement or a: if; else; then if eth0:4 is a match then put in eth0:4 IP How would you get the IP in your script as a variable if you have multiple IP's ...
-3
votes
0answers
39 views

Regex: match word in line 1-3 times

My question is about regular expressions and searching for text. I need to search for all lines in text that contain one ceratin word, let's say "cat", one, two or three times.
0
votes
1answer
34 views

Vim: Count all occurrences (including multiple on the same line) of char or word

I try to count all occurrences of a char or word in a file with Vim. This means multiple occurrences of the same word in the same line should be taken into account as well. This has been discussed in ...
0
votes
2answers
73 views

How can I filter ping results by time?

How do I filter out any pings that are under a certain ms, ie, only echo ping responses above 500ms to the text file? IP=$1 SECONDS_Between_Pings=$2 ping -i $2 $1 | while read pong; do echo $(date) ...
0
votes
1answer
23 views

text processing

I have two files. file A : Chr1 Cufflinks exon 2903 3268 . + . gene_id "XLOC_000001"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.1.2"; tss_id "TSS1"; ...
4
votes
3answers
126 views

Remove duplicate lines while keeping the order of the lines

[root@server]# awk '!seen[$0]++' out.txt > cleaned awk: (FILENAME=out.txt FNR=8547098) fatal error: internal error Aborted [root@server]# The ""server"" has: 8 GByte RAM + 16 GByte SWAP, x>300 ...
3
votes
4answers
235 views

Using sed for brackets

I would like to find out, if, in my file, there is a right number of brackets. I can make my file look like (((()))()(())) ((()))() How can I use sed to compute those brackets and print yes or no ...
2
votes
4answers
146 views

How do I extract the first integer from text string in a column of a tab-delimited file?

I work in Medical Genetics and often have delimited text files where in one column (ex. column 5) there is a text string with a "mutation" in our jargon: c.2458C>T or c.45_46delAA or ...
0
votes
1answer
22 views

How to find & replace pattern WITHIN specific pattern using sed

IT seems that 'sed' and I will never be friends... How can I find and replace a pattern within a range (within another pattern)? In words: Find: AllowOverride None within the following range and ...
0
votes
2answers
32 views

Vim: Substitute based on another match in the line

I have rather large files in which I need to substitute NX for N1 but only if the line already contains NX as a pattern. So far I do it manually by first searching for occurrences of NX with: /NX ...
2
votes
1answer
58 views

Using find and sed to copy 20th line of many files into one file

I have a folder called "PKA1" Within this folder I have several folders that look as: 1eV, 2eV .... 30eV Within each of these I have subfolders I have a file called PKA.dump I want to copy the ...
4
votes
2answers
142 views

Increment a variable using a Bash script

I have a file that contains the following text. // // test_file.h // test project // // Created by Test User // #ifndef test_file_constants_h #define test_file_constants_h // Generic includes ...
5
votes
5answers
361 views

How to replace a word with new line

I have a text file with following data and each row ends with |END|. T|somthing|something|END|T|something2|something2|END| I am tryig to replace |END| with \n new line with sed. sed ...
0
votes
1answer
44 views

Error while passing variables for keyword match using sed

I am a beginner in scripting. I am writing a bash script for text processing where this command is giving me error: sed -e "/\<$7\>/ /\<$5\>/$6/" < "$2/$1" > "file.tmp" This is ...
5
votes
7answers
430 views

Turn list into single line with delimiter

I have to take a list (loads) of IP addresses in this format: 134.27.128.0 111.245.48.0 109.21.244.0 and turn them into this format with a pipe in-between (IPs made up) 134.27.128.0 | ...