Manipulation of text by programs, scripts, etc.

learn more… | top users | synonyms

0
votes
0answers
14 views

How to extract a search string from a line in AIX?

How can I extract a string from a line looking for a pattern? For example: [6/25/16 19:13:10:364 ART] 0000300d SystemOut O INFO [WebContainer : 190] trip.c2c2 (Custom1344449048133....
4
votes
1answer
45 views

ANSI code translator

Is there any tool that translates text with ANSI code to text-like output? tput cap names or the like? Reason for the inquiry is that I would like to use script or the like and view the resulting ...
1
vote
3answers
53 views

Substitute a column i text file with incrementing numbers

I need to do something very similar to this Replace string with sequential index, but I don't need to add a number to a column, but substitute a whole column with incrementing numbers. Like this: 0 ...
0
votes
2answers
27 views

How to extract string between Nth and Mth occurrences of a pattern?

I have a file path.txt with the path to a file(say a txt file): /Folder/F1/F2/F3/F4/.../Fn/abc.txt I want to extract the path i.e the string from beginning to the last occurrence of / (since the ...
4
votes
2answers
48 views

Compose string of IPs using bash command line

I have a command that returns the following: id1="172" id2="17" id3="136" id4="5" id5="0" /> id1="172" id2="17" id3="128" id4="2" id5="0" /> id1="172" id2="17" id3="128" id4="4" id5="0" />...
3
votes
5answers
281 views

Add space between files paths

I have a list of folders and inside every folder I have the file " file.txt" which has the same name in all the folders. I wanted to collect the path for this file from all the folders and save it in ...
3
votes
2answers
103 views

Add a line below each line matching a pattern only if not already present

Can sed add a new line below a specific content, if the input content exist then leave it ? Current content of the file ssss Hostname example.com Os version rhel5.6 apache 4.2 Hostname example2.com ...
1
vote
1answer
34 views

Extracting from Logs

Actual logs are: 2016-06-19 22:08:09 [213917] 1bEgCe-000tZR-E9 ** saadia@aol.com (fahad@manakintextiles.com) <fahad@manakintextiles.com> F=<james@designplus.com> P=<james@designplus....
0
votes
2answers
30 views

BASH get value from string

I have this string stored in a variable <li class="rainbow-list-item southern disrupted " data-line-id="lul-southern" data-severity-codes="4,6,9" data-mode="national-rail"> and I would like ...
7
votes
5answers
597 views

How to find lines that begin with **

I need to find if any lines in a file begin with ** . I cannot figure out how to do it because * is interpreted as a wildcard by the shell. grep -i "^2" test.out works if the line begins with a 2 ...
1
vote
1answer
35 views

Compare dates in a list

So I have a list of dates and I need to develop a script that keeps a rolling count of how many dates are older than 14 days (date --date="14 days ago" +%Y%m%d). Not sure how I can have the date check ...
0
votes
0answers
39 views

Bash script: read file for strings and output those lines to new .txt file, what's the best route?

I have a spreadsheet(.xlsx) that I need to scan for 5 strings from only 1 column, then I need to output those rows to a new text file. It has to be a bash script, i.e. no perl/python/ruby, and from ...
0
votes
2answers
45 views

How to cut fasta sequence at specific numbers and generate ORFs

I have a file as shown below: CDS join(36..56,37..67) CDS 36..183 CDS 457..565 CDS join(505..519,521..596) CDS join(577..591,725.....
1
vote
1answer
49 views

insert the content between the matching pattern in shell script

I want to insert the content between the matching pattern in shell For example : file called input.txt : var a = [ ] file called output.txt : 1152 1185 1185 I want to insert the values ...
1
vote
2answers
67 views

how to use \n( and )\n as delimiter in awk

I have a file which contains below data 7[label = "ScanStep: T_b0\n(T.a = 1)\na\nb\nc\nd\ne\ndob\ntimestamp1\nUnc: Integer(8)\nUnc: Integer(8)\nUnc: Varchar(80)\nUnc: Numeric(10,2)\nUnc: Varbinary(80)...
1
vote
2answers
67 views

Retrieving five random items from a list using sed

How can I retrieve randomly selected five different items from a list using sed? My list is something like below. Each item begins with an asterisk at the beginning of a line. * asterisk* star ...
2
votes
2answers
25 views

less combined with sed color sequences prevents page breaks

If I use the command below which colors the lines output in yellow, it essentially turns less into cat, printing out the entire file and disabling all of the features I need with less, such as ...
6
votes
3answers
617 views

I need to find all users home directories listed using grep from /etc/passwd

so I have a question similar to another one on this site where the individual had to find a list of all users using grep or awk from /etc/passwd. that worked for me but I've tried translating it to ...
1
vote
1answer
61 views

Need to strip off the comments in double quotes

I have test case which contains string message in double quotes and I want to strip off data in double quotes. I used awk command to strip off comment section data but it doesn't work awk '/^"/ { ...
0
votes
1answer
52 views

Using multiple sed commands for text manipulation

I have a bash file, in which I would like to make several changes. sed -i 's/ / /g' testfile sed -i -e 's/#[a-z]$//' -e '/^$/d' testfile sed -i 's/ *$//' testfile sed '/##=/ r header' ...
0
votes
1answer
36 views

Proper way to convert PDF to word from bash command-line

I need to convert 1K pdf files to doc on a debian server. I can convert a PDF to word using libreoffice commandline: libreoffice --headless --invisible --convert-to doc Sample-doc-file-100kb.pdf Or ...
3
votes
3answers
39 views

awk to cut portion of a field and still print entire line

I have this line: 08:30:02.480507 IP 192.168.100.150.65119 > 192.168.100.151:53 59865 [1au] A? click.em.redbox.com. (48) I need to cut out the ".480507" in the timestamp so the line looks like ...
1
vote
3answers
79 views

Find and Replace with command line

my log.txt file includes ... mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 ... how can I replace mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 with mynetworks = 127.0....
2
votes
2answers
103 views

Extracting positive/negative floating-point numbers from a string

I am trying to extract numbers out of some text. Currently I am using the following: echo "2.5 test. test -50.8" | tr '\n' ' ' | sed -e 's/[^0-9.]/ /g' -e 's/^ *//g' -e 's/ *$//g' | tr -s ' ' This ...
0
votes
0answers
30 views

shell scripting using sed

I want to compare specific string surrounded by alphanumeric and some special chars in file. For example: 5efa4083-7157-437a-ab9a-652ced2fc2ea;: AAA :;5efa4083-7157-437a-ab9a-652ced2fc2ea;BBB I ...
1
vote
2answers
49 views

Make the 1st column as header and list its corresponding values using shell script

I have a large file contents are as shown below :- Quantity 20589 Quantity 12297 Quantity 100346 Quantity 0 Quantity 141999 Quantity 23662 Quantity 551071 Quantity 72917 ...
2
votes
1answer
29 views

Merging specific columns of 2 files based on field match

I know I'm not the first one asking this but my code still does not work: File 1: gi|1283| tRNAscan exon 87020 88058 . - . transcript_id "Parent=tRNA-Tyr5.r01"; gi|3283| tRNAscan exon 97020 97058 . +...
1
vote
2answers
132 views

Remove leading whitespace before possible shebang

I have a large collection of non-binary files in one place. Some of them have shebangs and of those some have (for some inexplicably reasons) whitespaces in front of the shebangs. This includes empty ...
0
votes
1answer
44 views

Why Blank output of this `sed … <<END_SED | cut …`?

The following sed returns (...| od -c) without ...|cut -d "\n" -f 0000000 1 9 2 \n 2 5 0 \n 0000010 Pseudocode # http://unix.stackexchange.com/a/290407/16920 sed -n -f - /usr/share/...
-3
votes
2answers
38 views

Convert text file to matrix format [closed]

I have a input files with 3 columns each- File1 - SNP Sample ID Genotype RS1 Sample1 AG RS1 Sample2 GT RS1 Sample3 AG RS2 Sample1 AG RS2 Sample2 TT RS2 Sample3 GG RS3 Sample1 GG RS3 Sample2 AG ...
2
votes
1answer
107 views

Read from and append to file at the same time while preserving end-of-line

Conceptually I have an easy task... I have [loosely] structured data in a file: Testing: debug, default CXXFLAGS <100's of additional output lines> Testing: release, default CXXFLAGS <100's ...
3
votes
2answers
346 views

grep: How to find Closing Bracket?

One part of /usr/share/X11/xkb/symbols/us starts with xkb_symbols "dvorak" { and ends with the closing curly bracket }; which line-number I want to find. partial alphanumeric_keys xkb_symbols "...
3
votes
5answers
355 views

converting spaces into dashes

Given a file with multiple lines, I want to change every space to dash. I did like that: #!/bin/bash while read line; do echo "${line// /-}" done This works just fine, but I need a better ...
2
votes
2answers
72 views

Grep for dates older than 14 days in a file [duplicate]

I'm trying to find a way to grep how many messages in a file are older than 14 days and have a value of number of results return Example going with today's date of 20160616. $grep 'Put Date' filename:...
0
votes
4answers
55 views

Delete specific line numbers (passed as variable) from a file in linux

I have two files. One having list of lines (which I don't require) say Seqlist and other text file (from which I intend to delete those corresponding lines) say ContentFile $cat Seqlist 3 4 ...
3
votes
1answer
47 views

How can I Split a text file into new files

I have a text file in the following format: 001|fileA 002|fileA 003|fileA 004|fileB 005|fileB 006|fileC . . . xxx|fileX I need to split this file into the files corresponding to each "|". The names ...
1
vote
2answers
27 views

Insert text inside stanza at the end of the data string

I have a file I need to echo text into at the end of the file from the command line, the problem is the data is in a stanza, all within curly braces. This is the end of the file: text-string1,text-...
1
vote
2answers
45 views

sed: Grabbing and replacing all data between last backslash and a comma

I have data in a csv format that looks like this: F1309-042543,07/14/09 01:39:25,N/A,C:\windows\system32\netsh.exe,N/A,True F1309-042543,11/21/10 03:24:02,N/A,C:\Windows\System32\networkexplorer.dll,...
3
votes
3answers
114 views

edit repo file with sed

I want to edit manually my repo file from the command-line, preferably using sed. How can I do that based on the repo-name I want to edit? I want to search for a specific repo-name (example: reponame-...
1
vote
2answers
55 views

Creating a text file from other text files

I have a text file like this word_1 root_of_word_A word_2 root_of_word_B word_3 root_of_word_C word_4 root_of_word_A And other document like this root_of_word_A root_of_word_1 root_of_word_B ...
1
vote
2answers
44 views

How to move string from one line to another

I have been editing a large text file containing pairs of lines as follows (repeated): \> destination_file.txt js -e "var e='.jpg',t='b',i='14712583',h='0.us.is.example.com',s='/',n='WIV',u='...
0
votes
3answers
82 views

Splitting a text file into new files

I have a text file in the following format: Model 1 Atom…. Atom…. Atom…. ENDMDL Model 2 Atom…. Atom…. Atom…. ENDMDL Model n Atom…. Atom…. Atom…. ENDMDL I need to split ...
2
votes
2answers
64 views

How to get the last occurrence of lines between two patterns from a file?

I have a log file which reports on the output of a process, I'd like to extract all lines from between the last occurrence of two patterns. The patterns will be along the lines of; Summary process ...
4
votes
2answers
40 views

Is it possible to print an iterated range of arguments via cli from a csv? (see example)

I have hundreds of logs spread across a few thousand VM's and I'm trying to create a few scripts to quickly scan logs and I have figured out the majority of the presentation and wanted to know if ...
0
votes
3answers
63 views

How do I find the string after a regexp on a single line of text?

I have a text file containing a very long line of JSON data and I need to extract the value of some field.  I realize the easiest way to do this would be to use jq or grep -o; however, I am on a ...
-1
votes
1answer
26 views

how to save one line as one file with counter number names

I have a file like this: VLLKHCGRMRRFLIRNLRSFLSHISLNTLKSQESKV LLSSQAKMYFSLRENFYLEGGIETTFVPSGEVYSRSFLKGISRI LNPNALPTSPISENWVMVRPIVAQISLRRMTPSAIGAQTEMA ...
-5
votes
3answers
97 views

How to add all the numbers of a specific column in UNIX without using awk command?

Let us take a sample file with the contents below, an expense report containing items and their prices: $ cat file Item1,200 Item2,500 Item345,900 Item20896,800 Item111,600 Now, a friend challenged ...
2
votes
2answers
126 views

Multiplying numbers in-place in a file

I have ASCII file contain numbers as follow: 1 2 3 5 6 9 7 8 9 . . . . . . . . . . . . . . . etc I want to upgrade this file by multiplying each value by "3" to get : 3 6 9 15 18 27 21 24 27 ...
2
votes
1answer
34 views

Tweak perl script for human-readable dmesg output

In RHEL 6 I have the kernel parameter: printk.time=1 So that my dmesg would have a timestamp. However it shows in seconds from restart, like this: [12.23456] I found a script that you place ...
-2
votes
2answers
61 views

Find all line in a file which start with g or any digit from 0to9

How do I find all lines in a file which start with g or any digit from 0 to 9? Can any one help me using command line? I try and I know how to do if start with g but don't know how to do with g and 0 ...