Questions tagged [text]

56 questions
133
votes
9 answers

How to remove empty/blank lines from a file in Unix (including spaces)?

How do I remove empty/blank (including spaces only) lines in a file in Unix/Linux using the command line? contents of file.txt Line:Text 1: 2:AAA 3: 4:BBB 5: 6:CCC 7: 8:DDD output desired…
Michael Ellick Ang
  • 1,839
  • 3
  • 13
  • 15
76
votes
5 answers

How do I grep through binary files that look like text?

I have binary files that should be text (they're exported logs), but I can't open it with less (it looks ugly - it looks like a binary file). I found that I could open it with vi and I can cat it (you'll see the actual logs), but what I'd really…
Robyn Smith
  • 861
  • 1
  • 7
  • 5
9
votes
6 answers

How can I export all group policies to a easily-parseable format?

I need to dump all the Group Policies within Active Directory to review offline at a later date. Is there a way I can easily export all the Group Policies to text or some other easily-parseable format? Edit: Will these tools work from a computer…
romandas
  • 3,242
  • 8
  • 37
  • 44
7
votes
4 answers

get text between keywords in log file

If I have a log file and want to dump only the text between 1234 and 9876 in to another file, how can i do this easily? If I have a text file like this: idsfsvcvs sdf sdf e e sd vs d s g sg s vc d slkdfnls 1234 keep me text 9876 das a g w eg dsf…
Darkmage
  • 323
  • 3
  • 12
6
votes
8 answers

How to remote control Windows?

Is there a way to remote control a Windows machine as easy as I do with my other Linux pcs through SSH? I'm currently using a FTP server for files but I prefer the way I can manage my other linux boxes. I'd like it to be textual just like ssh, is…
Andrea Ambu
  • 480
  • 1
  • 7
  • 13
5
votes
3 answers

"group by count" for IPs in text file in linux

I've got a huge textfile which contains IP addresses: 123.33.22.33 221.23.128.2 123.33.22.33 92.222.192.12 92.222.192.12 123.33.22.33 I can sort it to: 123.33.22.33 123.33.22.33 123.33.22.33 221.23.128.2 92.222.192.12 92.222.192.12 and see (with…
cherouvim
  • 744
  • 3
  • 18
  • 37
5
votes
1 answer

How can I replace line #6 in a text file in a bash script?

I have a text file that is generated by 3rd-party software as part of a build process. I want to replace one specific line - in my case, line 6. How can I do this in my bash script? I suspect sed is my friend here but I'm now stumped. I'm using Mac…
Steve McLeod
  • 190
  • 1
  • 1
  • 10
5
votes
3 answers

Best way to remove text from the beginning of a huge file

I have a huge MySQL backup file (from mysqldump) with the tables in alphabetical order. My restore failed and I want to pick up where I left off with the next table in the backup file. (I have corrected the problem, this isn't really a question…
Christopher Schultz
  • 1,056
  • 1
  • 11
  • 20
4
votes
4 answers

How to decipher Powershell syntax for text formatting?

I found a PowerShell script that I thought I could adapt to my purposes. It contains this line that formats the output: $largeSizefiles = get-ChildItem -path $filesLocation -include $Extension -recurse -ErrorAction "SilentlyContinue" | ? {…
tim11g
  • 425
  • 5
  • 9
  • 21
3
votes
1 answer

Removing control characters from a text file

I started a unix keystroke log with script temp.txt; however, it captures my keystrokes verbatim (backspaces, arrows, etc...). What is the best way to remove the control characters from a file named temp.txt that I created with script…
Mike Pennington
  • 8,266
  • 9
  • 41
  • 86
3
votes
1 answer

replace text in file without overwriting file

I want to use the command line to edit a text file but not overwrite it. I want to preserve the owner, group, and permissions of the file. I have a file that holds a count of the number of times a piece of equipment is used. This file lets me know…
joshxdr
  • 257
  • 3
  • 15
2
votes
3 answers

Tool for multiple pattern search and replace

I am looking for an easy to use tool that will allow me to have batch of search/replace pairs. Rolling out to different environments requires us to search/replace server names in database scripts. I would like to create a list of search/replace…
Mike Schall
  • 241
  • 2
  • 5
2
votes
0 answers

server for replacing text

I have a large key-value database of words. Each entry is a word that replaces another word. I am given a continuous stream of text where I have to replace the words with corresponding words in the database. For example when I want to cache web…
nurettin
  • 370
  • 2
  • 9
2
votes
1 answer

How can I remove old log entries from a log file and archive them somewhere else in Linux?

CentOS 4.x I apologize in advance if this is not the appropriate place to ask this question. It pertains to a linux server / IT admin task. I've got a log file on an old CentOS 4.x server and I want to remove log entries older than a certain date…
Mike B
  • 11,570
  • 42
  • 106
  • 165
2
votes
2 answers

find and replace text with sequence of numbers

I need to replace a word in a file like this text text pc text text text text pc text text text text pc text text i need to replace pc with pc1, pc2 .... etc text text pc1 text text text text pc2 text text text text pc3 text text How can i do this…
cosmin
  • 121
  • 1
  • 2
1
2 3 4