Terminal of unix can be without square brackets - unix

Can i make look like root#arch$.
Instead if [root#arch~],
I don't like square braces.
Help me if you know i want to remove square[] bracess.

The prompt you're talking about is named PS1, and you can customise its appearance in your .bashrc file.
So edit that file and add something like the following:
PS1="\\u#\\h:\\w"
The next time you log in you should have your new appearance.

PS1="\[\e[1;31m\]\u\[\e[0;15m\]#\\h \\w "
Insert the above code in '~/.bashrc' file, whenever you open a terminal '~/.bashrc' file will be executed hence you get custom prompt.
Tinker with numbers above to get desired colors.

Related

Remove line feed in CSV using Unix script

I have a CSV file and I want to remove the all line feeds (LF or \n) which are all coming in between the double quotes alone.
Can you please provide me an Unix script to perform the above task. I have given the input and expected output below.
Input :
No,Status,Date
1,"Success
Error",1/15/2018
2,"Success
Error
NA",2/15/2018
3,"Success
Error",3/15/2018
Expected output:
No,Status,Date
1,"Success Error",1/15/2018
2,"Success Error NA",2/15/2018
3,"Success Error",3/15/2018
I can't write everything for you, as I am not sure about your system as well as which bash version that is running on it. But here are a couple of suggestions that you might want to consider.
https://www.unix.com/shell-programming-and-scripting/31021-removing-line-breaks-shell-variable.html
https://www.unix.com/shell-programming-and-scripting/19484-remove-line-feeds.html
How to remove carriage return from a string in Bash
https://unix.stackexchange.com/questions/57124/remove-newline-from-unix-variable
Remove line breaks in Bourne Shell from variable
https://unix.stackexchange.com/questions/254644/how-do-i-remove-newline-character-at-the-end-of-file
https://serverfault.com/questions/391360/remove-line-break-using-awk

Is there a way to default to "Replace in all cells" in the "Find and Replace" in jupyter?

I usually want to find and replace all, but it looks like it has been set to current/highlighted cell only (https://github.com/jupyter/notebook/pull/2131). jupyter also doesn't remember the option after the dialog goes away. Is there a way to change this behavior? Thanks.
Select all the cells where you want to perform Find/Replace
Shift + Arrow key Down or Up
and then,
Menu: Edit -> Find and Replace
Press ctrl+shift+F.
Then type "find and replace".
In order to rename a variable in all cells, click on the arrow as shown in the image
Steps
1.Go to edit -> Find and Replace -> click on it
See the highlighted option. Use this to replace in complete notebook.
I just had to do it urgently so shut down the notebook kernel did it from the terminal with sed like this:
sed -i "" 's/oldword/newword/g' mynotebook.ipynb
That was on a mac which am using at the moment, but if you do it on ordinary linux the "" should be left out ie
sed -i 's/oldword/newword/g' mynotebook.ipynb
First time I ever needed to do such a thing in years but if it happened more often would be good if it could be done from the browser.
First select all the cells (Esc->Ctrl+Shift+arrow_down_key).
Then Edit-> Find and Replace.
If only in one cell, then use the shortcut 'F' key.
Just do ctr+a outside the cell thats all:-
It will select all the cells and perform find and replace

Programmatically modifying a specific line in a text file

Help with what I suspect to be pretty simple would be much appreciated.
I want to be able to programmatically change a certain line in a configuration file. Specifically, the file looks like
...Other lines...
# The name of the database to mount
dbms.active_database=test.db
...Other lines...
I want to be able to replace "test.db" with "production.db", etc. Other programs may add or delete lines, so I can't count on a consistent line number, but there is no other line containing "dbms.active_database="
How might I best do this?
Thank you.
With sed:
sed 's/\(^dbms\.active_database=\)test\.db/\1production.db/' file
awk -v name0fNewDb="HEythere.db" 'BEGIN{FS=OFS="="}/dbms.active_database/{$2=name0fNewDb}1'
...Other lines...
# The name of the database to mount
dbms.active_database=HEythere.db
...Other lines...
If I understood problem statement right, this should help you in doing the changes only on the line which consist of "dbms.active_database". Where it will replace the right part of = . name0fNewDb is a variable to which you can assign any text of your requirement.

inserting line breaks after every record in the textpad

I have a textpad file that has rows of text. For e.g.
Cat: Meaning - animal. The cat ran up the house
Rat: Meaning- rodent. The rat lives in the borough and feeds on leftovers
Word 3: Description
Word 4: Description
I have many such record in my file. I want to insert a line break at the end of every record for proper presentation. Doing it manually is tedious. Please help if you know an automated process to insert line break.
You can quickly do this by using a feature called "Regular Expressions" to find and add empty lines.
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following: (^.+$)\n(^.+$)
In the "Replace with" field, type the following: \1\n\n\2
Tick the "Regular expression" checkbox
Click the Replace All button at least twice, but perhaps 3 times, until you get the message Cannot find the Regular Expression
Untick the "Regular expression" checkbox
Close the Replace dialog
Confirm the file is formatted as you are expecting
Save the file.
You can write a simple C# prgram that uses a loop that adds this code after every line :
But first add the namespace using System.Enviorment
Enviorment.NewLine;
If you have any more trouble i'll help with some code to get started
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following so that the replace occurs at the end of each line: $
In the "Replace with" field, type the following. Note each 'n' represents a <return>. In this instance, I added a return at the end of a SQL statement, the word 'GO' on the next line and another <return>: \n\GO\n
Started with text file containing:
select * from <tablename>
select * from <tablename>
Ended with text file containing:
select * from <tablename
GO
select * from <tablename>
GO
Hope that helps.
from your text it is difficult to understand what you are intending to do. I'll give you some questions. The answers will help others to help you.
Do you really mean textpad as the product from company helios in UK or do you use this word as a general word for a class of tools (like notepad - but there is a general definition AND the tool as part of Windows).
Your file hase line breaks yet. You don't see them, but in the file itself they are present (in Unix systems line feed (hex code 0A) or in the windows world carriage return followed by line feed (hex code 0D 0A)).
Or would you like to publish your text in HTML? So you have to put the necessary tags around each line like paragraph, line break, list item etc.?

Aptana: find and replace tabs (with spaces)

I am belatedly setting up Aptana to use four spaces instead of tabs. I've made the necessary changes to the preferences so every new tab inserts four spaces.
All the existing tabs remain, however, and so I get Mixed spaces and tab errors. How can you do a Replace all to fix this? I've tried ^t, <TAB> etc but it just searches for these as normal strings. What are the correct ways to specify a space and a tab?
I've found myself in similar situation and copying whole source code and repasting it helped me out. Just do as follow on your source code Ctrl+A, Ctrl+C, then Del whole code and Ctrl+V it again. You will get only spaces if have set it in options like you mentioned above.
There's an option in the refactor source menu to convert between tabs and space-tabs.
This worked for me: Edit > Find/Replace... (CTRL+F), check Regular Expressions, type \t and type 4 spaces (I use 4 spaces for tab).

Resources