Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

text-processing

Delete range of lines above pattern with sed (or awk)

August 7, 2022 by Magenaut

I have the following code that will remove lines with the pattern banana and 2 lines after it:

Categories Q&A, Unix & Linux Tags awk, sed, shell-script, text-processing Leave a comment

How to truncate text lines to N characters maximum?

August 7, 2022 by Magenaut

Given a text file, or the output of a command, how can I truncate it so that every line longer than N characters (usually N=80 in a terminal) gets shorten to N characters maximum? Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve … Read more

Categories Q&A, Unix & Linux Tags cut, text-processing Leave a comment

Read columns from file into separate variables

August 7, 2022 by Magenaut

I need to read the following input into separate columns as variables?
input.txt

Categories Q&A, Unix & Linux Tags bash, command-line, text-processing Leave a comment

Filtering invalid utf8

August 7, 2022 by Magenaut

I have a text file in an unknown or mixed encoding. I want to see the lines that contain a byte sequence that is not valid UTF-8 (by piping the text file into some program). Equivalently, I want to filter out the lines that are valid UTF-8. In other words, I’m looking for grep [notutf8].

Categories Q&A, Unix & Linux Tags character-encoding, command-line, text-processing, unicode Leave a comment

Converting CSV to TSV

August 7, 2022 by Magenaut

I have a number of large CSV files and would like them in TSV (tab separated format). The complication is that there are commas in the fields of the CSV file, eg:

Categories Q&A, Unix & Linux Tags csv, perl, python, text-processing Leave a comment

Counting occurrences of word in text file

August 7, 2022 by Magenaut

I have a text file containing tweets and I’m required to count the number of times a word is mentioned in the tweet. For example, the file contains:

Categories Q&A, Unix & Linux Tags cut, grep, text-processing Leave a comment

tail -f, but with line numbers

August 7, 2022 by Magenaut

I’m trying to see how many times foo bar appears in /var/log/foo.log within an arbitrary amount of time on a remote server, but nothing that I’ve tried so far has worked.

Categories Q&A, Unix & Linux Tags logs, portability, text-processing, ubuntu Leave a comment

Is there a command line spell to drop a column in a CSV-file?

August 7, 2022 by Magenaut

Having a file of the following contents:

Categories Q&A, Unix & Linux Tags text-processing Leave a comment

How do I remove certain lines (using line numbers) in a file?

August 7, 2022 by Magenaut

There are specific lines that I want to remove from a file. Let’s say it’s line 20-37 and then line 45. How would I do that without specifying the content of those lines?

Categories Q&A, Unix & Linux Tags text-processing Leave a comment

How to sort the string which combined with string + numeric using bash script?

August 7, 2022 by Magenaut

This is the data what I want to sort. But sort treats the numeric to string, the data it no sorted as I expected.

Categories Q&A, Unix & Linux Tags bash, shell-script, sort, text-processing Leave a comment
Older posts
Newer posts
← Previous Page1 … Page12 Page13 Page14 Page15 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress