Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [text-formatting]

Questions about using command-line utilities such as awk, sed, perl, pr, etc. to format text files. For printf format strings, use [tag:printf]. For date format strings, [tag:date]. See also [tag:text-processing].

0
votes
5answers
62 views

file formatting using awk

My input file contains data in the following format: 1503668542862176 manager=10001|Bounced=999|Analyst=10004|Business Analyst=10005|Programmer=10003 1552024948590636 manager=10001|Bounced=999|...
0
votes
3answers
38 views

Combining multiple columns and insert information in middle

I have to 3 files with all containing columns of information id.file 1 2 3 name.file Josh Kate Chris lastname.file Smith Jones Black And I would like to combine them in a way, so I can get ...
-1
votes
2answers
30 views

Swapping the contents of two columns

I am trying to understand cut better and moving cut data to another file. I have a file called numbers with two columns. Each column is separated with one tab. I am trying to swap the columns by ...
0
votes
5answers
59 views

How to add a string in column n and first line of a file?

I have a tab-separated file that looks like: $ cat file GCF_000014165.1_ASM1416v1.dist_nbr_anntn WP_011558474.1 1155234 1156286 polyketide synthase [Mycobacterium] GCF_000014165....
-1
votes
1answer
44 views

Form an unstructured record into structured record in UNIX script

Using UNIX script the following code to be developed. I have a file 20-40 GB data contains data like below. Providing sample records. AUTO="text1" CAR="its mine" LORRY="commercial vehicle" CART="...
1
vote
5answers
59 views

Question about text formatting using sed of awk

I want to format text using awk or sed. I have text looking like, H1 (dxfault) H337 (Unxr) H1106 (hast) H1129 (h1129) H1370 (hlan1370) I want to remove the letter H and everything after the first ...
11
votes
2answers
401 views

Delete all lines which don't have n characters before delimiter

I have a very long text file (from here) which should contain 6 hexadecimal characters then a 'break' (which appears as one character and doesn't seem to show up properly in the code markdown below) ...
1
vote
1answer
69 views

How to get du -ksh working without a carriage return in shell-scripting?

Working on a script to fit a specific format. I need the results of the command to be echoed between pipes | X |. When I try to use du -ksh it always brings a carriage return. Any idea how to deal ...
0
votes
2answers
68 views

text processing between 2 patterns in awk to give selective unique output

I have below input file, Policy Name: KE15-LOCALHOST-APP-RADIX-DAILY Policy Type: Standard Active: yes Include: /appussd /home/ussd2ke /var/...
1
vote
1answer
57 views

Placing the last line first in each html <ul> with sed

I try to place the line "name: *****" just after the corresponding (innermost containing) "ul" each time an "ul" appears, so that it looks like this: Before: <ul> <ul> <li ...
2
votes
1answer
65 views

replace indentation tabs with fixed number of spaces per tab

Is it possible to replace only "leading tabs" with a set number of spaces per tab? I'm defining a leading tab as one that is only preceded by tabs or spaces. I'm defining a leading or an indentation ...
0
votes
2answers
27 views

How to combine two text formatting commands into one?

How does one combine two commands like the ones shown below into one command with one output file? first command: printf '%s\n' {001..500} input > output second command: sed 's/^/PREFIX /; s/$/ ...
0
votes
2answers
43 views

Format the output of commands

I am currently trying to use Plink to run a few commands on a linux server to monitor a couple of things on it such as the disk space, memory, cpu usage. I have the commands that I want to use but I ...
1
vote
3answers
69 views

Print SSH loop output Column wise

I want to print output of below loop into columns, Can anybody please adivse me on this. #!/bin/bash DATE=`date "+%d-%m-%Y_%H-%M-%S"` ### Find User from Server with Expiry Date for i in `cat /home/...
0
votes
3answers
74 views

How to break a long string into multiple lines assigned to a variable in linux bash script

I am working towards writing a bash script that contains a variable with a long string value. When I split the string into multiple lines it is throwing error. How to split the string into multiple ...
-2
votes
1answer
53 views

Why does echo -e “\n” give me two blank lines instead of one?

Let's say there's a line "aaaa" in file.txt, and I want to add ONLY ONE blank line after it, and then add a line of text after the blank line. I did: echo -e "\n" >> file.txt echo "bbbb" >> file.txt ...
-1
votes
3answers
62 views

Print 1st column of 1st row and 2nd column of last row, where last column has same value [closed]

Input: 0.016 0.032 1 0.032 0.048 1 0.048 0.064 1 0.064 0.08 1 0.08 0.096 1 0.096 0.112 1 0.112 0.128 0 0.128 0.144 0 0.144 0.16 0 0.16 0....
1
vote
1answer
35 views

Multiline sed script error: newline can not be used as a string delimiter

I am trying to get this sed command to work: sed -e \ 's|$API_URL|$(API_URL)|g ; \ s|$API_KEY|$(API_KEY)|g ; \ s|$API_SECRET|$(API_SECRET)|g ; \ s|$API_SALT|$(API_SALT)|g ;...
-2
votes
1answer
346 views

Display Student Record in Unix [duplicate]

Write a command or logic , which will read the contents from the given input file and fetch the Students of School named as Sangamithra. Input File format: The sequence of columns in the input file(...
0
votes
1answer
43 views

To delete the counter line numbers and time-lines in a file

I have a file which is a subtitle (sub.srt or a text file) of a movie. But I wonder if there is a short way to delete all line-numbers and time-lines of the file. For example 85 00:07:39,250 --> ...
0
votes
1answer
24 views

show volume informations in tabular view

I'm trying to save on linux powershell core 6.1 information about the volumes in a variable. Best in the same or similar format as it is possible on windows. But i am unable to achiev this kind of ...
0
votes
0answers
31 views

Why are trailing line breaks stripped when used as an argument (for echo)? [duplicate]

When I run this… echo " fdsfsd dsfsdf " I really get the output of all these lines. However, if I use this output as an argument for echo again…: echo "$(echo " fdsfsd dsfsdf ")" …...
0
votes
0answers
30 views

Convert to Single line output of bc command [duplicate]

echo 'obase=2; 3402823669209384469321375 ' | bc 10110100001001001101110000110101000010010101110011010101100110001011\ 01011010011111 I would like to convert the multiple line output into a single ...
0
votes
2answers
158 views

Concatenate strings with literal tab and new line character

I've a tab/space delimited file as: 31000BL 50014_10011 25467BL 50050_10003 47406BL 50001_10015 40831BL 50114_10006 40830BL 50114_10009 Two columns. I use a ...
1
vote
1answer
25 views

Print table with empty columns for consecutive delimiters

I typically use column to convert input into a table, eg: $ echo 'a\tb\tc\nd\te\tf' | column -t -s $'\t' a b c d e f However it collapses empty columns eg: $ echo 'a\tb\tc\nd\t\tf' | column -t -...
0
votes
1answer
56 views

print number of lines and words in a single line with one spacing in shell scripting [closed]

When I am using wc -lw filename, I am getting output separated into two spaces. But I want only one space separated. How to do this?
0
votes
1answer
111 views

make json from SQL query output

I have this query: select hostname,size from tableinfo output is like this: hostname size ------------------------- ----------- host1 28 host2 ...
0
votes
0answers
37 views

How can I regex match-and-replace _all_ on-screen text?

I need a way to replace an on-screen pattern with another string, regardless of what places that text on the screen. Maybe I can live without user input being replaced, but anything that comes from ...
0
votes
2answers
41 views

Omit one column in ls -hal

How do I omit the group column in the output of ls -hal? I was using ls -hal|cut -f4 --complement -d ' ' and it works find most of the time, but if I run it in / I get scrambled output: drwxr-xr-x ...
4
votes
1answer
149 views

Sort multiple delimited file lexicographically by one column, numerically by another

I wish to sort the TSV file below (called min_ex) by the first column lexicographically and by the second column numerically. A X, N 2.2 A, N 5.7 A, A 5.8 A, N 2.1 A, T 0.2 B G, M 2....
1
vote
3answers
85 views

print a column with the desire format output [closed]

I have a list of the following data in a file: -0.3476890000000000 0.0743938333333333 -1.0990240000000000 0.0743938333333333 -0.2169100000000000 0.0879397500000000 and I am ...
0
votes
1answer
36 views

How to filter text, removing lines where a specific position is empty

# lshw -c network -businfo Bus info Device Class Description ======================================================== pci@0000:03:00.0 enp3s0 network I210 Gigabit ...
2
votes
4answers
131 views

How to break line after matching case but needs to go back a couple of characters

I have the following sample: 1. TNT 00:00 2. Swing From The Gutters 7:34 3. Ten-Day Interval 13:29 4. I Set My Face To The Hillside 18:16 5. The Equator 24:26 6. A Simple Way To Go Faster Than Light ...
1
vote
2answers
62 views

How do I align columns at common elements but give differing elements their own rows?

I am using paste to merge three text files (which do not require sorting) into a single document with three columns. paste a.txt b.txt c.txt I'd like elements that the columns have in common to ...
2
votes
2answers
77 views

How can I get less to display \n as a newline?

I have some files containing \n newlines that I am viewing with less. I would like to be able to have less display those newlines as actual newlines. For example an array: Array\n(\n [Color] =&...
0
votes
1answer
99 views

AWK print specific fields without specific word

Input: a-0;Password-1010;c-ss;d-fk;h-14;i-jawad;j-dd;Email-1@1.com; a-7990:15:71;b-aa;c-1;Password-2020;h-iOS;Email-2@2.com; Output: 1@1.com,1010 2@2.com,2020 my input file is the same as my ...
0
votes
0answers
29 views

Display a bash script and all its functions in a visual way

Is there a tool (general or bash / shell specific) that can display a code into in clean visual representation of the functions. Like a visual algorithm with bubbles with the name of the functions ...
0
votes
2answers
37 views

How to avoid data trimming while formatting file in unix

I have a file in below format A |b -c | c | d -c | | | And I need to format the above file like below A|b -c|c|d -c||| Please note, I don't want to remove the space ...
-1
votes
1answer
154 views

Why text in the gnome-terminal has characters slightly overlapping themselves

This is the screen shot of my gnome-terminal: You can see that all the text is messed up. The username is heman and the host name is arch linux but the characters are not even readable because they ...
0
votes
2answers
197 views

Formatting output with printf piped in with xargs

I want to search my code base for ocurrences of a string, and then get the formatted output as filename, line number, and code lide. I got it as I wanted on the first line of the output, but the ...
0
votes
1answer
177 views

Embed ascii diagram in groff?

I have groff file to generate a pdf in the format: .TL Article title .AU Author name .AI Publication title .SH .LP First paragraph .PP More paragraphs I'm then running groff -ms a.ms -T pdf > a....
0
votes
1answer
62 views

Formatting ps output based on given parent/child processes

Given a list of process names, I want those parent/child processes to not appear in the output of a ps --forest call. This will reduce the processes that I need to look at when I'm tracking things.
1
vote
1answer
96 views

How to align a string variable in Bash

I'm trying to align a string variable in Bash. This is the desired behaviour. if str1="123" , then str2=" 123" if str1="1234" , then str2=" 1234" if str1="12345", then str2=" 12345" etc. I'...
4
votes
2answers
133 views

How to get traditional email clients to send email which appears normal in Gmail?

A considerate friend informed me recently that emails I send (with Neomutt; could be Mutt or Gnus or Pine) look funny on his device: Apparently Google doesn't invest much effort in properly ...
-1
votes
2answers
47 views

reformatting table with various copy paste

I have something like this in a file: 00550 Peptidoglycan biosynthesis (2) K01000 K02563 00511 Other glycan degradation (6) K01190 K01191 K01192 K01201 K01227 K12309 I need something like this : ...
0
votes
1answer
18 views

how to reformat Kegg mapper output in linux?

I need to reformat the kegg reconstruct pathway output, I have something like this in file1: 00550 Peptidoglycan biosynthesis (2) K01000 K02563 00511 Other glycan degradation (8) K01190 K01191 ...
1
vote
3answers
87 views

Bash output two results next to each other

I have an out from xmllint and egrep that I would like to print two fields next to each other. e.g. (xmlinput) xmllint --format | egrep reference\|sourcefile <reference>ItemX</reference> &...
0
votes
2answers
336 views

How to get Hexdump output in same format as hexedit?

I'm trying to get the output of my hexdump command to look similar to hexedit default. I've been playing with the format strings using -e, but since there are not very good documentation, that ...
0
votes
3answers
61 views

Organizing data by a header

I have two csv files. File 1 contains header. File 2 contains data file 1 format : file1.csv id,abc,xyz,aaa,bbb,ccc file 2 format : file2.csv id,source,value 1,abc,100 1,xyz,...
-1
votes
2answers
192 views

Add four lines between sentences [duplicate]

Is there an easy way to add four empty lines between each sentence. For example, this paragraph: This combination of vitamins and selected minerals is used to prevent or treat vitamin deficiency ...