Questions tagged [line]

28 questions
26
votes
10 answers

How to remove empty lines from beginning and end of file?

I would like to remove empty lines from the beginning and the end of file, but not remove empty lines between non-empty lines in the middle. I think sed or awk would be the…
Feriman
  • 919
  • 1
  • 10
  • 13
22
votes
2 answers

check command line arguments

I would like to check if the first command line argument ($1) has an minimum amount of 10 characters and if it is empty. The script is called as: ./myscript.sh 2018-08-14 I tried this but it doesn't work timestamp="$1" # check if command line…
user305422
  • 221
  • 1
  • 2
  • 3
13
votes
2 answers

How to make a continuous vertical line in vim?

I want to make a table in vim. Making a horizontal line is easy ______________________________ For the vertical I use this yes "|" | head -10 But the result is bad | | | | | | | | | I want something contiguous like the horizontal line. How can I…
elbarna
  • 12,050
  • 22
  • 92
  • 170
5
votes
3 answers

Help with Find command: Find files or folders that start with a space (ore more than one space) on linux

How do I do a search for any of the following: Find folders that start with a space on linux and then remove any starting spaces so the folder can start with a letter or a number? Find FILES that start with a space on linux and then remove any…
JustAl
  • 139
  • 1
  • 4
5
votes
6 answers

sed: delete all lines before matching one, including this one

TARGET How to delete all lines in a text file before a matching one, including this one? Input file example: apple pear banana HI_THERE lemon coconut orange Desired output: lemon coconut orange The aim is to do it in sed to use the "-i" option…
taalf
  • 53
  • 1
  • 3
4
votes
2 answers

Is there a way to count the number of lines of text in a file including non-delimited ones?

The POSIX wc command counts how many POSIX lines in a file. The POSIX standard defines a line as a text string with the suffix \n. Without \n, a pure text string can't be called a line. But to me, it's more natural to count how many lines of text…
Just a learner
  • 1,766
  • 4
  • 22
  • 32
2
votes
1 answer

Showing line numbers by default in ed

In the ex editor, one can show line numbers by default by adding this line to a .exrc file: set number Is there a way to have ed start with line numbers showing by default, when lines are invoked?
Edman
  • 472
  • 2
  • 9
2
votes
2 answers

In a file to find and replace/change multiple strings in a line with shell script

I am new to shell scripting What I have is a log file, each line begins like the below entry, [2021.04.27.17:03:43.813]: ERROR - [2021.04.27.17:04:36.790]: SUCCESS - The desired output to a new file is 2021-04-27 17:03:43 813,ERROR, 2021-04-27…
Mathewshr
  • 23
  • 3
2
votes
4 answers

Read file line by line with awk to replace characters in certain line numbers

I have got this script here. It is supposed to run the loop by reading the file LineNumbers.file line by line (each contains a line number) and then accordingly replacing 0/0 with ./. in the BEFORE_File.txt. It works, but it takes only the very last…
P. HamB
  • 35
  • 1
  • 5
1
vote
1 answer

merge x and x + n lines

I am writing a script which returns 15 lines of titles and 15 lines of URLs. title 1 title 2 title 3 *snip* title 14 title…
1
vote
3 answers

How to make text wrap with diff -y?

When I use diff -y to compare two text files with long lines of text, the result cuts off each column and I cannot read an entire line. I would like instead the text to wrap (or fold as it is also called) so that I can read the whole line. For…
xenkan
  • 11
  • 1
  • 2
1
vote
1 answer

Bash script Issue parsing text in line with whitespace characters

I have a list of commands to parse through for an audit, similar to this: 1. -a *policy name=PolicyName -a *policy workflow name=PolicyWorkflow -a *policy action name=PolicyAction -s Server -b Storage -J Node -y 1 Months -o -F -S 2. -a *policy…
1
vote
1 answer

sed command to replace a word from one file with entire line of another file

I want to use the sed command (or something that works) to replace a word in a template file with a word in a line of another file. As an example I have a file with a list of words, each word is in a different line and I want to use sed to take the…
1
vote
3 answers

fix slapcat 79 character line wrap in output

I use slapcat to do a full-text search in our very large ldap directory. As it is easier to match what I am looking for when I don't know where to look. The problem is that it wraps long lines slapcat -v | grep -A 1 "some search…
nelaaro
  • 1,333
  • 3
  • 15
  • 20
0
votes
1 answer

How to search an argument/flag/option in man with a line break?

In man argument/flag/option chapters generally include a line break, as with: -s silent How could I find only the -s which includes a line break after it, just as in the above example? The purpose is to prevent a case where I find an -s inside…
Lahor
  • 113
  • 8
1
2