Questions about modifying, creating or parsing plain text files. This is a very broad tag, if your question is about using a specific tool, please tag it with the tool's name as well (e.g. sed, awk, perl, etc.)

learn more… | top users | synonyms

0
votes
0answers
27 views

Update URLs in one file with URLs in another file

I have a local text file that, among other things, contains a list of URLs that expire periodically. There is a file on github that I can pull on occasion that has the updated URLs. Each of those URLs ...
0
votes
1answer
54 views

How to extract a rectangle of text from a file in CLI?

Huge note: I AM NOT TALKING ABOUT TEXT EDITORS! I need to extract (stdout is OK) a rectangle of text from a text file. A rectangle should be the text between lines l1 and l2 and columns c1 and c2. I ...
0
votes
2answers
23 views

bash script to run a second command with select output from first command as variable

I'd like to get the output of the second command with the 7 character PSI domain (00:01.0) as a variable. How can I write a bash script to do this? jeff@jeff-probook:/$ lspci | grep VGA 00:01.0 ...
1
vote
3answers
82 views

How can I extract pdf names from an lftp log file?

I have a log like this : 2016-05-11 07:09:54 ftp://test@test.dyndns.info/test1/fool/1999/How/05%20May/test160511.pdf -> /test/keep/more/use/05/test160511.pdf 0-28442281 33.5 KiB/s i need to ...
0
votes
1answer
62 views

How can I get and change a value of a line inside of a file if the value of such line is unknown by me?

What I am trying to do is: There's a file, inside of it, there's a line (it surely will be there, 100%) in this model: name_of_the_value=xxx Where the value is numerical and unknown by me because ...
-1
votes
3answers
41 views

UNIX -grep 2nd character

So here's a sample line in my script: echo "Enter time(MILITARY FORMAT)(i.e 1245): " read time` so for example the user's input is 1315 how do i grep the 3rd and 4th digit (15) and then the output ...
6
votes
8answers
399 views

How to remove brackets () around ip address from traceroute output

I need to extract the 2nd IP address from a traceroute like so traceroute -m2 8.8.8.8 |grep .net |awk '{print $3}' (111.222.333.4444) No matter what I try I can't seem to work out how to remove the ...
3
votes
3answers
169 views

How do you extract a particular column or row from the output of a command?

Example: abcd@abcd-abcde:~$ xinput --list --short Virtual core pointer ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)] ↳ Logitech USB RECEIVER id=12 ...
3
votes
3answers
83 views

How to remove XML-like tags from input?

I'm updating my .bashrc file to show weather I'm using the line lynx -dump "http://wxdata.weather.com/wxdata/weather/local/14225?cc=*&unit=f&dayf=1" | grep -A 2 -m 1 "<tmp>" Which ...
0
votes
1answer
44 views

printing distances of desired character based on occurance

This is an extension of my previous question (Printing pattern of "C" character). I would like to print "C" character from "text" column given in file.csv. The file.csv has two coloumns as ...
2
votes
1answer
54 views

How to use sed with file path variables AND regex callbacks AND arithmetic expressions

I'm having a hell of a time getting the proper syntax using sed with variables containing a file path, a regex callback and an arithmatic expression. I don't know how to properly escape things. I ...
1
vote
1answer
23 views

how to replace 3rd row in a file using sed?

I need to change a variable in a file using a bash script, i think sed is the way to go but i can't figure out the regular expression. I have tried replacing a character in the file but then ...
0
votes
0answers
35 views

Mass delete of emails from text file found in word document

I've got two files. The first file is about 700 email address that I have in a text file, the second file is my complete email list which includes first name, email address. What I need to do is do ...
1
vote
2answers
52 views

Get unique lines from log using grep and tail

I have the following log file. I want to extract the last 10 unique entries from this file. Is it possible to do with grep and tail? 2016-04-18 10:13:11,925 (glastopf.glastopf) 115.239.248.245 ...
1
vote
1answer
23 views

How to replace string containing file path using sed

I want to replace a file path to other using sed. I am attaching a small part of my file Kindly help source file : Dir=D:\test\foo Dir=D:\test\bar the result should look like this ...
3
votes
5answers
318 views

How do I merge tab-delimited files?

I have 3 tab-delimited files as shown below: File 1: 1 Hhe.7 2 Hpyl.1 10 Hac.2 File 2: 3 Hac.2 15 Hpyl.1 33 Hhe.7 File 3: 70 Hpyl.1 23 Hhe.7 9 Hac.2 How do I merge these files ...
3
votes
5answers
511 views

How do I transpose a row to a column in a tab-delimited file?

I have a tab-delimited file with a number and the names belonging to the same number on the same row. The number and names are separated by a tab. The names are linked with each other by 2 underscores ...
1
vote
3answers
193 views

How to remove all but number from hexdump output?

I have got the base64 output for a huge file, the output is also obviously huge and in a file of its own, I wanted to convert the big number in it to base10 so I have now used hexdump to get it into ...
0
votes
2answers
31 views

Replacing a Substring with sed

So I've got a line that looks like this ish somelongbullshit:888:morelongbullshitthatcanhaveanything And I want to replace the second : with a tab character. I can reliably match the substring I ...
2
votes
1answer
40 views

How do I use variables and non-variables in a single sed command?

I'm trying to use sed to replace some PHP lines. My problem is I want to replace a line with PHP variables with a string including a Bash variable. Here is an example: sudo sed -i 's/$sUrl . ...
2
votes
3answers
243 views

String replacement with iterator

I have a file with a character I would like to replace, but I also want to have each instance of the character(s) to be replaced, be iterated with a number inside the sting replacement. SomeFile.txt ...
2
votes
4answers
169 views

How do I join two CSV files but only where 2nd file matches?

I have 2 CSV files: Objects File: IP,MASK,DESCRIPTION 10.10.3.94,255.255.255.255,Rob 10.10.3.95,255.255.255.255,Mark 10.10.3.96,255.255.255.255,John Services File: DESCRIPTION,OrgIP,Service ...
2
votes
1answer
44 views

How to delete multiple lines from txt file, based on a variable in previous column?

The idea is this: I have a document with data listed in the following way (shown below), and I want to delete any line that has a value of 70 or less in the 6th (last) column. On top of that, I want ...
1
vote
2answers
218 views

Crop a string using sed

I have a command that outputs me a list with the following pattern exp_70_T8_s1 exp_71_T8_s5 exp_72_T8_s10 exp_73_T10_s1 exp_74_T10_s5 exp_75_T10_s10 ... How can I get the numbers after "_T" and ...
-1
votes
2answers
78 views

Joining 2 files and comparing them [closed]

I have two files where I want to use something like a left join that is used in SQL. File1: column1 column2 column3 column4 Ab Cd 100 Us Ef Gh 200 Us File2: ...
1
vote
1answer
34 views

Replace text in one file and match in second file

I have two text files, file1 and file2. In file1, I would like to start the numbering in the second column (after the space) from 0. However, this new numbering should match the numbering in file2. ...
4
votes
3answers
277 views

grep command for a text file in multiple directories

I have 24 directories in a specific directory (main_directory). Each 24 directory have a text file whose name is DATA.txt. I need to use grep command to extract below specific pattern for each text ...
1
vote
2answers
82 views

remove special character using sed

I have a text file that contains following https://git.centos.org/git/rpms/abc.git https://git.centos.org/git/rpms/abc.git/ https://git.centos.org/git/rpms/abc When I run the following command, ...
1
vote
2answers
220 views

How do I replace '<p>' with '<p>\n' and '</p>' with '\n</p>' using sed?

I have following file and I want to replace <p> with <p>\n and </p> with \n</p> using sed. My input file contains the following lines: <p>This is home.</p> ...
1
vote
2answers
209 views

Get a specific word using awk

I am coding a script to check mysql databases using bash script, I would like to check if the status of a table is not 'OK', will return the table name and do some more actions: check.log table1 ...
6
votes
5answers
1k views

Get one element of path string using bash

I have an ASCII file containing filepaths which I read by running: while read p; do echo $p; done < filelist.txt The file contains filepaths with the following pattern: ./first/example1/path ...
9
votes
6answers
706 views

How to convert from row to column?

I have a .txt file with numbers ordered like this (on the same row): 106849_01373 106849_01967 106850_00082 23025.7_01059 I would like to convert them like that: 106849_01373 ...
1
vote
3answers
87 views

split txt file in half based on pattern

I have a text file which looks like this: train/a/abbey/00000001.jpg 0 ... train/a/abbey/00000999.jpg 0 train/a/abbey/00001000.jpg 0 train/a/airport_terminal/00000001.jpg 1 ...
0
votes
1answer
25 views

List all binaries a package provides

This is not a duplicate of listing all files a package provides, i want to list all binaries a certain package provides that are in the standard location for binaries. I know this can be done with ...
5
votes
2answers
148 views

Split file into two files when pattern appears using command

I want a simple command (either AWK, Perl etc.) to split the file into two files as shown below. test.pem: -----BEGIN PRIVATE KEY----- ...
0
votes
1answer
29 views

Suppress command output lines that contain a certain string

When I run an arbitrary command in the terminal in linux, is there a way to suppress output messages that contain a certain sentence? I tried ./mycommand | grep -v "I dont want to see this" but ...
1
vote
2answers
49 views

How can I get the last occurrence of a repeated string in the text file?

I have a data file consists of several rows and columns with numeric and string data. Some string and numeric patterns are repeated. I need to extract last repeated pattern. For example; 715 ANKR PRN ...
4
votes
2answers
96 views

How do I compare two files containing several md5 checksums to determine changed files?

I have two files MD1 and MD2. MD1 contains md5sums: 5f31caf675f2542a971582442a6625f6 /root/md5filescreator/hash1.txt 4efe4ba4ba9fd45a29a57893906dcd30 /root/md5filescreator/hash2.txt ...
-1
votes
3answers
40 views

How to get specific portion of a command result?

From the result of this command: diskutil info / | grep "Free Space" which is something like this: Volume Free Space: 31.5 GB (31519584256 Bytes) (exactly 61561688 512-Byte-Units) I want ...
0
votes
1answer
33 views

How to delete all `uuid=“*-*-*-*-*”` attributes in an XML file using the terminal?

Here is my code in myfile.jrxml. All I want to do is to delete all the uuid="contained_value" attributes. I've searched them with grep -ir uuid *. How to delete them? <band height="50"> ...
3
votes
2answers
96 views

Run shell script to take output of a file and convert it into Excel format

I have data in two different files called test1.txt and test2.txt, like: ID : 1 Name: xxxx Age: 33 Education: Mtech ID: 2 Name: yyyy Age: 22 Education: bsc I want to print these lines using a ...
0
votes
2answers
35 views

searching about specific word in a Directory then delete it

I search in a directory for a given word in text files by this shell script instruction grep -r "$2" "$1" $2 is the directory $1 is the word How can I delete this word after it?
1
vote
1answer
414 views

extracting information from file

I have a file like: number_of_x 100 # total number of x number_of_y 2000 # total number of y total_rate 1.67 # rate blah1 0.876 # blah1 blah2 10450 # blah2 I would like to ...
3
votes
1answer
145 views

Sort file/folder output in Bash

I have output like this (alphanumerical): bash /etc/file bash /etc/filenew bash /etc/skel/ bash /etc/skel/file bash /etc/skel/filenew bash /etc/skel/new/backups/ bash /etc/skel/new/file bash ...
0
votes
1answer
30 views

change format table in ubuntu [closed]

There is a file I have it looks like 1 11063 upstream_gene_variant 1 13011 intron_variant&non_coding_transcript_variant 1 13259 ...
3
votes
5answers
92 views

How to remove lines which contain asterisk by using sed command

I have a file which contain following lines. **;**;**; *(Eng_Sen:This is an apple)*;*(WordID:1 2 3 4)*;*(message:)*; **;**;** I want to delete all the lines which contain following patterns using ...
1
vote
2answers
55 views

Remove everything before first occurence of specified word

How can I remove everything before the first occurence of a specified word using sed? What I have tried so far: echo $(cat /etc/nginx/sites-enabled/default | sed 's/^*.server/server/') > ...
2
votes
4answers
47 views

Trim beginning of a text file

I have a text file with unexpected spaces at the beginning and would like to trim the beginning and save it. How can I do it? I have tried a very simple example I have found on the internet but it ...
9
votes
1answer
469 views

Is there a way, ideally using the command line, to convert multiple .csv files to one multi-sheet .xls spreadsheet?

Is there a way, ideally using the command line, to convert multiple .csv files to one multi-sheet .xls spreadsheet? If there isn't a cli solution, it'd be good to know if there's an API that works ...
3
votes
2answers
87 views

How do I get a list of users not present in a CSV file from /etc/passwd?

I need to compare the user list (/etc/passwd) to a .csv file of account and get the account from /etc/passwd that are not in my csv file. /etc/passwd shows: root:x:0:0:root:/root:/bin/bash ...