Skip to main content

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 the [printf] tag. For date format strings, [date]. See also the [text-processing] tag.

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

is a cell boldface

I'm looking for a function to determine if a cell is formatted bold. I'm using LibreOffice Calc, and for ease of use, I have a range of items to buy and their prices. I want to have a simple method of ...
Michael Gehrke's user avatar
2 votes
1 answer
158 views

Cannot open an .mbox file with neomutt (although it works with mutt)

Cannot open an .mbox file with mutt I want to open a 10GB .mbox file that I downloaded from my gmail account. When I use the command neomutt -f 10GB_mboxfile.mbox neomutt takes 10-20 seconds to open ...
ecjb's user avatar
  • 465
0 votes
0 answers
36 views

Different format in .mbox and email saved locally with mutt: convert split .mbox file into the same format as mutt?

I am trying to move to mutt for mail client and am trying to have email localy. I have 2 sources of saved email: the first one was obtained from the .mbox file form google: I wrote a script which ...
ecjb's user avatar
  • 465
0 votes
1 answer
124 views

How do I change the date/time format in syslog-ng from `mmm [d]d hh:mm:ss` to `yyyy-mm-dd hh:mm:ss`?

I noticed that the default datetime format for logs in /var/log/messages is mmm [d]d hh:mm:ss, for example: Jan 4 03:46:50 1.2.3.4 ntpclient[6952]: Failed resolving address to hostname pool.ntp.org: ...
skeetastax's user avatar
0 votes
0 answers
74 views

Text processing grep and awk together on live script not working

I am using ssh to login to a remote server (Ubuntu), and then issue a command which outputs text/value each sec (live script). In the live output, I want to filter out the lines containing '...
SAM's user avatar
  • 1
0 votes
2 answers
42 views

process a text file to modify a column value based on maximum value from another column

I have a file that i am looking to modify. There are 100's of files having the same issue. the input file is below sample1 100A total 1 1000 sample2 100A total 1 5584 sample3 100A ...
bioiinffun's user avatar
1 vote
2 answers
94 views

Reformat text to exact width [duplicate]

On Ubuntu, how to reformat text to fit width (except final line), adding spaces where necessary? The closest I can get is with fmt --width=64, but this does not add the spaces between words. Input ...
FromTheStackAndBack's user avatar
1 vote
1 answer
31 views

How do I format the output of cut to the following format? [duplicate]

last part of the command: | cut -d' ' -f3 output: 4 10 required format: 4,10 I'm guessing echo (and sort?) is to be used in some way, but I can't quite place my finger on it.
kesarling's user avatar
  • 159
2 votes
1 answer
49 views

text formatter that supports bullets

I am looking for a formatter to use with my git commits. par pretty much does what I want, with the (important) limitation that I can't get it to properly format bullet lists, which are pretty common ...
m000's user avatar
  • 181
0 votes
0 answers
101 views

Find and replace in CudaText editor

So I have dump from U-boot and I need to replace specific string in CudaText editor. Here is mine text e101b1e0: 30ef27d8 e792f415 9beea618 5c601de4 .'.0..........`\ e101b1f0: aeaf9d25 e1dd63e9 ...
Slobodan Vidovic's user avatar
-2 votes
1 answer
289 views

Template for formatting output as a dynamic table in bash

I have a created a simple script which is using the ps aux command to give information for a process entered by a user, and presents the output in a table like format (something like the mysql shell ...
October's user avatar
  • 11
2 votes
0 answers
43 views

Generate upper-case in a udev rule?

I have a use case with cross-platform context which makes me want to generate symlinks under a /dev/disk/by-X directory that have an uppercase version of data returned by blkid. Is there a built-in ...
RJVB's user avatar
  • 254
1 vote
1 answer
64 views

Sed - replace a string with a character of another line

I am trying to write a script to reformat some text. pages: page1: gui-rows: 6 items: '6': material: CAT_SPAWN_EGG buy: 999999999 sell: -1 '7': ...
Pegoku's user avatar
  • 11
3 votes
5 answers
748 views

How can I reformat blocks of data until the end of the file is reached?

I have a file that looks like this: # Time-averaged data for fix avetimeall # TimeStep Number-of-rows # Row c_gyrationchunkall 1000 3 1 2.09024e-14 2 4.88628 3 5.69321 2000 3 1 2.10518e-14 2 8.33702 3 ...
Felipe Evaristo's user avatar
1 vote
1 answer
87 views

How to preprocess output of any CLI Tool in realtime?

For context, what I am trying to do is add a preprocessor to a REPL, more specifically, nix repl. Although this would probably apply to any other REPL like application. The reason for it is that I ...
Mathias Sven's user avatar
1 vote
5 answers
140 views

Add two delimiters after every sixth comma

I'm trying to expand on this question but can't figure out this issue: Let's say I've got a file roll.txt: echo "'123456789','987651234','129873645','213456789','987612345','543216789','432156789'...
jophuh's user avatar
  • 33
1 vote
2 answers
212 views

Recursive pattern search - output formating: for each match file print out the specific file name "\n", line number, sentence matched "\n" in colors

I want a file content search command, under Linux so that: it will search on specified files, e.g: md, txt, htm. recursively from the folder and its subfolders, e.g: . the content search can be ...
user2718593's user avatar
0 votes
0 answers
80 views

How can I parse the output of w to collect current user sessions?

I want to parse the output of w so I can collect current user sessions and record them via telegraf. However, it only provides space separated output and I'm not sure how to reliably parse this ...
Zac Pullar-Strecker's user avatar
3 votes
2 answers
87 views

fixing or finding an alternative to bad 'paste <(jcal) <(ccal)' output

(I don't have a high enough reputation to comment my question into: how to show stdout outputs of two programs side by side ) I've tried paste <(jcal) <(ccal) but the output is messed up. jcal; ...
YQ002lc2's user avatar
1 vote
2 answers
56 views

Change irregular header with extra whitespace

I am working with data in this obscure file format: SNP A1 A2 F1 I1 F2 I2 F3 I3 rs0001 A C 0.02 0.00 1.99 (Note the whitespace around the first three fields) The header is long (500k ...
Giulio Centorame's user avatar
-2 votes
2 answers
59 views

How to group matching data from first two column [closed]

I would like to group data from first two fields as per below Sample Data: CHECK|checkadm|block1 CHECK|checkadm|block2 CHECK|checkadm|block3 CHECK|checkadm|block4 TEST|testadm|block1 TEST|testadm|...
Rocky's user avatar
  • 3
-1 votes
3 answers
138 views

Joining multiple lines based on a regex

I have the output of a pandoc conversion to HTML which looks like this: foo bar <blockquote> That's one small step for man, one giant leap for mankind A new line and another quote </...
Josh Friedlander's user avatar
1 vote
1 answer
70 views

"par" formatter does not retain tab indentation

I'm writing code in Vi and using the par text formatter (similar to fmt, but IMHO better) to format block comments. The issue is that I can't get par to keep the literal tabs I use for indentation. ...
Kusalananda's user avatar
  • 341k
3 votes
2 answers
1k views

How can I pretty-print or beautify GraphQL text from the command line?

I have a GraphQL query in GetPerson.gql that is all scrunched up on a single line: { getPerson(id: 42) { name, age } } How can I pretty-print or beautify this text using the command line? $ magical-...
Cory Klein's user avatar
  • 19.1k
1 vote
1 answer
260 views

Script to select a PulseAudio sink from an ordered list and use its name as command input

I wish to write a bash script that will create a PulseAudio loopback device between an audio source and a bluetooth device. (Context - skippable) So far I have (the relevant part of) my script as: ...
Marc.2377's user avatar
  • 1,112
1 vote
1 answer
231 views

pretty-print css one-liner

I (human) would like to read this ~30000 chars long line of CSS. @font-face{font-family:KaTeX_Script;src:url(/static/fonts/KaTeX_Script-Regular.af7bc98.woff2) format("woff2"),url(/static/...
Poor Standard's user avatar
4 votes
3 answers
2k views

Visually aligning columns of a CSV file

Using sed or awk, is it possible to visually align columns in a CSV file? For example: e.g. from: a,b,c,some stuff,"some, other, stuff",d,2023-03-10 18:37:00 y,x,z,t,cool,thing,2022-04-12 21:...
s.k's user avatar
  • 471
3 votes
1 answer
2k views

How to print leading zeros (padding) in awk?

I am trying to print 99.11111 as 099.11 in AWK. I have tried the following variations without success. $ awk '{printf ("%000.2f\n", $1);}' <<< 99.111111 99.11 $ awk '{printf ("%...
ychaouche's user avatar
  • 1,008
-1 votes
1 answer
66 views

How can I format the output of a shell command into columns, but limit the number of columns created?

Say I run systemctl | grep running | column -t I get an output that looks like this: init.scope loaded active running System and Service Manager session-...
DrKumar's user avatar
  • 119
3 votes
2 answers
295 views

How to Replace Multiple Lines using Files on Termux

Assume I have many *.txt files on directory texts with the below contents. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam tincidunt mauris eu risus. Vestibulum auctor dapibus neque. ...
zakadmin's user avatar
3 votes
2 answers
178 views

Indent Fortran source code, propagate indentation down to unindented special lines

I'm trying to write my own script to improve some auto-formatting before commiting to a remote repository. I use indenting guides in my IDE and the autoformatters available for my language (FORTRAN) ...
Philip Moloney's user avatar
2 votes
1 answer
1k views

How does awk print the columns in right-justify?

I have INPUT data like this: V 0.886 3.768 -2.882 C -0.082 3.768 -3.850 M -0.900 3.769 4.669 F -0.001 3.768 -3.769 I expect OUTPUT formatting like this: V 0.886 3.768 -2.882 C -0.082 3.768 ...
Binh Thien's user avatar
1 vote
3 answers
83 views

Writing bash arguments with trunctation

I want to print the first two arguments of a bash function, with the unicode character \u2263 on each side using a two space separation. The thing is that the final unicode must display at column 70. ...
Vera's user avatar
  • 1
0 votes
3 answers
75 views

Add custom delimiter in key-value pair

I have data which are in "Key:value" form (901 S 902 M 905 F 906 WAPENC 907 31 908 371 909 38765469947/TYPE=PLMN and so on ) where keys are 901,902,905,906.....so on and respective values ...
Sunny's user avatar
  • 23
2 votes
2 answers
127 views

Add custom delimiter in key-value form data

I have data which are in "Key:value" form where keys are 901,902,903,904 and respective values are S,M,F,WAP`, with space as delimiter. Input example 901 S 902 M 903 F 904 WAP ..... I want ...
Sunny's user avatar
  • 23
0 votes
2 answers
205 views

How to echo a string inside a category in a ini file with quotes

I have an ini file like for example [Admin Prefixes] # Here you can add custom prefixes to specific players or flags that are shown when using $admin_prefix$. # Syntax: "type" "info&...
ph3ro's user avatar
  • 378
0 votes
2 answers
336 views

convert xterm256 to ansi

I have a program that will only accept ANSI color input but I have reason to feed it the output of a program that outputs xterm256 color codes. Is there a converter? I realize of course that color ...
Ray Andrews's user avatar
  • 2,547
2 votes
1 answer
131 views

Arithmetic operation in terminal from an output

I want to print the lines of updates via this command dnf check-update --refresh --q --downloadonly | wc -l However during the output there occurs a blank line which means the true update number is ...
Neptune's user avatar
  • 153
0 votes
1 answer
158 views

highlight command refuses to change theme

$ highlight -l -s clarity -S sh -O ansi some_file No matter what I try, highlight always shows the same theme. And it is supposed to create a file 'highlight.css' but it doesn't. What am I doing ...
Ray Andrews's user avatar
  • 2,547
1 vote
3 answers
258 views

text processing rows to columns for a block of lines Awk

i have input file like below .i need to reformat the text as o/p mentioned. I using the awk got from this forum but it is displayed based on the List A columns count. Please help awk 'BEGIN{ max=0 } ...
Renga's user avatar
  • 393
0 votes
1 answer
94 views

How to follow logs while avoiding line wrapping w/ horizontal scroll enabled?

In the terminal, if I don't want to have logs of a program wrap, I can pipe those to less -S. However, horizontal scroll with keyboard doesn't work unless I Ctrl+C, and after that, I don't know how to ...
doplumi's user avatar
  • 101
0 votes
1 answer
41 views

Split lines (like fmt -w) but on coloured / formatted command line output

I have output from a command (jest, for running automated JS tests) that uses fancy terminal codes to do things like coloured text in its output. I want to trim any very long lines because I run jest ...
Croad Langshan's user avatar
1 vote
2 answers
54 views

Transpose with row condition

Need help in formatting below test data in unix. Sample data: Dan serv1 p1 Dan serv2 p2 Dan serv3 p3 Dus serv2 p1 Dus serv3 p2 Dus Serv5 p3 Tes serv3 p1 Tes serv5 p3 Needed format: Name p1 p2 ...
Abi's user avatar
  • 19
2 votes
2 answers
325 views

Remove empty lines in tab delimited file while preserving row labels

I have a tab delimited file with column headers like ID, A, B, C, D as shown in the pic below, and row labels too like a, b, c, d, e show below in pic. How do I remove all the empty lines (rows) while ...
Ben M's user avatar
  • 21
-2 votes
1 answer
47 views

reformat numerical values to two values [closed]

I have a huge file with numerical values in many columns and rows. The values in the columns after column 6 are all numerical plus missing as NA (0 or 1 or 2 or NA). I would like to change values in ...
motor 30's user avatar
2 votes
2 answers
178 views

awk to change any values except 0,1, 2 to missing (NA)

I have a huge file with numerical values in many columns and rows. The values for columns are all numerical and 98% are [0 or 1 and 2]; However for some these are beyond 0,1 and 2, for example 1....
motor 30's user avatar
1 vote
3 answers
1k views

Insert character in middle of string

I would like to perform adding hyphen "-" character in my string. How would like to perform? vol0802-f522-6cc63-0a3-d I am getting the above about output. However, I need the following ...
Sandeep K's user avatar
0 votes
4 answers
64 views

Convert abc pqrs xyz on separate lines into 'abc','pqrs','xyz' on a single line, using awk

printf 'abc\npqrs\nxyz\n' | awk $'{ print "\'" $0 "\'" ,sep="," ,ORS=""}' Output: 'abc' , 'pqrs' , 'xyz' , expected output: remove last/ end of the comma(,) ...
user540652's user avatar
0 votes
2 answers
256 views

insert block of lines only before first matched pattern

i need to insert the below lines (after variable substitution) before the first matched string which is server { in /etc/nginx/nginx.conf Variable: website=www.hello.com Block of lines: server { # ...
Ashar's user avatar
  • 511
3 votes
6 answers
1k views

Splitting columns in TSV into CSV

I have a TSV file with two columns in the format of id1\tcol1,col2,col3 id2\tcol4,col5 I want to split the second column in combination with the first column to output id1,col1 id1,col2 id1,col3 id2,...
Googlebot's user avatar
  • 1,959

1
2 3 4 5
13