Why does ~ symbol is coming when ls command is given - linux

I was working on a desktop server of Ubuntu 12.04 through putty.
When I was giving the ls command in a directory the text file are given along with the same text file followed by a ~ symbol is provided.
Last login: Tue Nov 12 10:34:45 2013 from 10.3.61.19
ncclab#slave13:~$ cd benchmarks/
ncclab#slave13:~/benchmarks$ ls
config_fermi_islip.icnt gpgpusim.config RAY
data gpgpusim.config~ running benchmarks
DG gpuwattch_gtx480.xml running benchmarks~
MUM gpgpu_inst_stats.txt~
Any file of the name gpgpu_inst_stats.txt is not present actually in that folder. Why is this happening. May be question is simple, but I was curious to know the reason behind it

Generally that means either someone opened the file with a text editor and then saved, and the editor made a backupit's a temporary fileit's just just a file with a '~' in the name

Related

Hide username and computer name from Git Bash for Windows 10

Is there any way to remove the username and computer name from Git Bash for Window 10?
I already checked this : https://github.com/Maximus5/ConEmu/issues/199
But didn't understand how to do that.
Follow the steps below:
Go to C:\Program Files\Git\etc\profile.d\ folder
Find and open the git-prompt.sh file in your favorite text editor
Go to line number 15
Replace the whole line with PS1="$PS1"''
That's it. Start/Restart Git Bash and you should see the username and computer name is gone.
NOTE: You can also hide the annoying MINGW64 text by commenting out the line number 16 and 17 of the same file. To comment out those lines just add a # to the beginning of the line. That's it. Now start/restart Git Bash and it should go away.
Better way!!
Follow the steps as mentioned by #Saabbir, with one big change:
# 👇 comment out the wrapping if-else block
if test -f ~/.config/git/git-prompt.sh
then
. ~/.config/git/git-prompt.sh
else
# 👇 leave the content uncommented
...
fi
Save the file, git-prompt.sh using Save As (in your editor) in this path C:\Users\{current_windows_user}\.config\git
Explanation: You can see on line number 8 that it checks for the same file on ~/.config/git. So it's better to update the config file rather than the actual settings file.

The output of a .txt file created in vi editor show all the text in one line

I have a log file for my scripts to get report that is report.txt file. When I see it in vi editor it is showing as I want it to be :
Sanity Report
Start time:Fri Mar 10 08:08:33 CST 2017
LABS:
1: lht1-u0 (172.28.152.240)
2: lht1-u1 (172.28.152.241)
BUILDS:
CCM: 455
AMM: 395
OEBase: 864
ACS_DM: 569
AMS_DM: 707
TC Area TC Title Status
System-VM0 install ------------------------------------- Passed
System-VM1 install ------------------------------------- Passed
OpensSaf start ----------------------------- Passed
Verify alarmd server is -------------------------------- Passed
Product install of AMM ------------------------- Passed
Product install of AMM ------------------------- Passed
But when I open the actual text file in windows (this file should be email to a group of people) it shows all the text in one line.
How can I change this?
This is probably related to the end of line characters.
To my knownledge, on Unix and Windows, the convention differs.
DOS / Windows uses :
\r\n
Unix only:
\n
You need a way to convert your unix style end of line to the windows style.
The use of a regex engine can do the trick.
I found my own answer. I found it here https://www.maketecheasier.com/convert-files-from-linux-format-windows/ and I used awk 'sub("$", "\r")' uniz.txt > windows.txt worked well!
For anyone who has a file like this who does not have access to Linux, open the file with Wordpad (make a change??) and save it.
Next time you open it with Notepad it will appear normal.

How to edit file name under cursor in Vim/Gvim, when it starts with /cygdrive/ in Windows

With cygwin64 installed, and a separate Gvim 8.0.2 installation.
I can open a file on the bash prompt like this:
gvim /cygdrive/c/Temp/foo.txt
it works because my script uses cygpath -w /cygdrive/c/Temp/foo.txt to convert the path into its windows form, finally calling gvim.exe C:\Temp\foo.txt.
However in Gvim, when my cursor is on a line like this:
/cygdrive/c/Temp/foo.txt
and I type <Ctrl-W> f, I get this error text in Gvim:
E447: Can't find file "/cygdrive/c/Temp/foo.txt" in path
What must I do to get this working in a standard installation of Gvim under Windows?
You can use 'includeexpr' to modify the path found:
set includeexpr=substitute(v:fname,'/cygdrive/c','C:/','')
This will open C:/Temp/foo.txt instead.
See :help gf, :help 'includeexpr'
Have a look at what the file-line plugin does. You could develop a plugin for converting /cygdrive/... paths based on it quite easily.
Instead of hooking into *:* patterns, you'd use /cygdrive/*, and then convert the path, either in Vimscript (substitute()), or by invoking the external cygpath tool through system().
The plugin then replaces the invalid current buffer with the corrected file name, and loads that instead.
In the past, I did try to convert on the fly from vim end. I gave up eventually as there were too many side effects -- like an improper filetype detection. The idea would be to listen to BufCreateand/or BufNewFile event to open the correct file and close the invalid one. Here is a plugin that tries to correctly open file:lineno -- but with side effects :(
As most of my use cases were to open filenames in the quickfix windows, I first came up with a cygwin compiler plugin, then I moved it into build-tools-wrapper.
Create hardlinks to make these /cygdrive/c/path == /c/path == c:/path equivalent in NTFS:
start > cmd >
mkdir c:\cygdrive
mklink /D c:\cygdrive\c c:\
mklink /D c:\cygdrive\d d:\
cd c:\cygwin64
mklink /D c /cygdrive/c
mklink /D d /cygdrive/d
and as above in vimrc for gf
set includeexpr=substitute(v:fname,'^/cygdrive/\\(\\w\\)/','\\1:/','')
test:
echo 123 > c:/x
C:\cygwin64\> ls -al c:/x /cygdrive/c/x /c/x
-rwxrwxrwx 1 ad None 6 Mar 26 21:47 /c/x
-rw-r--r-- 1 a Users 6 Mar 26 21:47 /cygdrive/c/x
-rw-r--r-- 1 a Users 6 Mar 26 21:47 c:/x

add a permitted path to ghostscipt running configuration

I use a program which create me postscript file before using ps2pdf to make it a readable pdf, i've made a program which add some string to overwrite the company new logo. (The first program can't import image file itself).
I add the string before the before-last line of the file (" showpage").
While running my program to add the logo there is no error.
With the option -dNOSAFER everything is fine, but by default it's set to -dSAFER, and an invalidfileaccess error pop, the files are 6 jpg images alone in their directory.
I don't want to make it run with the -dNOSAFER option on. As it will fully open the file system.
In the documentation I've seen that there is a "permitted path" setting, but i can't find nowhere to set this up. Is it just a command line option to set in the command launching the program ? Or is there a config file for GhostScript / ps2pdf where i can put the path to this directory as permitted path.
in this documentation :
http://www.ghostscript.com/doc/current/Use.htm
I only find
-dTTYPAUSE
Causes Ghostscript to read a character from /dev/tty, rather than
standard input, at the end of each page. This may be useful if input
is coming from a pipe. Note that -dTTYPAUSE overrides -dNOPAUSE. Also
note that -dTTYPAUSE requires opening the terminal device directly,
and may cause problems in combination with -dSAFER. Permission errors
can be avoided by adding the device to the permitted reading list
before invoking safer mode
gs -dTTYPAUSE -dDELAYSAFER -c '<< /PermitFileReading [ (/dev/tty)] >> setuserparams .locksafe' -dSAFER
The quote is just for the context but is this a way to put the permitted path ?
As gs automatically launch with the full system as readOnly there will be no difference ? There is no other find result for PermitFile in this page.
Try adding the required path to the search path with -I (Include) See Use.htm, section 8 How Ghostscript finds files. This should only be a problem if you are using 'run' or similar to read files from another location.
The section on TTYPAUSE is not relevant.

How to update all the files under the current directory in Ubuntu with some comments at the start of the files

I have an issue where in, I am trying to add copyrights message in all our files in the project. Since it will affect many directories and files, our team has split the task.
so each on of us will be updating the files manually. Can I automate it.
I tried with:
find -exec sed -i "1i # x CONFIDENTIAL\n# _____________________\n#\n# 1997 - 2012 x Incorporated\n# All Rights Reserved.\n#\n# NOTICE: All information contained herein is, and remains\n# the property of x Incorporated and its suppliers,\n# if any. The intellectual and technical concepts contained\n# herein are proprietary to x Incorporated\n# and its suppliers and may be covered by U.S. and Foreign Patents,\n# patents in process, and are protected by trade secret or copyright law.\n# Dissemination of this information or reproduction of this material\n# is strictly forbidden unless prior written permission is obtained\n# from x Incorporated.\n" -- {} \;
It just stops, as soon as it encounters the . folder and any folder under the current directory.
Can we control the command to affect some of the files in the directory by specifying the complete/partial name of the file?
You can do so by executing the following commands for each file:
cp file temp
cat copy_right_notice temp > file
Note that > overwrites file (while >> appends to file, which is not what you want (referring to your comment))

Resources