一个人的角落,也许并没人会看到这里~~ 祝福你,工作顺心,学习快乐~

linux 输出重定向问题

> :用于左边指定描述符
&>/dev/null :此处& 指所有输出 ,即全部重定向 至 文件

2>1 :用于将错误输出重写向至当前目录的文件名为1的文件中

2>&1 :用于将错误输出重写至 标准输出

sudo 时 内部命令无法使用 IO重定向
调用 sh -c “command” 来运行命令

sudo sh -c "cat hosts >> /etc/hosts"

bash 启动参数复习

BASH的参数可以用$加数字编号来访问。

如$1代表第一个参数,$2代表第二个参数,以此类推.

但不能用$10来访问第十个参数,如果遇到参数超过十个的情况,必须处理或保存第一个参数($1),然后使用 shift命令删除参数1并将所有剩余的参数下移一位,因此$10就变成了$9.

$#的值将被更新以反映参数的剩余数量。

#!/bin/bash
i=1;
while (($#>0))
do
    echo $i, $1
    shift
    let i=i+1
done

显示了所有参数

Add Sublime Text to your context menu on right click

When opening a text file, you may be used to right click on the file to be opened and then choose the application which can open the file from the context menu. On the context menu, you may see a menu item like "Edit with Notepad++".

Nowadays many people especially programmers like to use Sublime Text, but by default this application will not show on the context menu when you right click on a file. There is now frequent request to add this application to the context menu. Here we show a simple batch file which can help you achieve this.

Below is the batch code :

@echo off
SET sublimeTextPath=C:\Program Files\Sublime Text 3\sublime_text.exe

REM ADD REGISTRY KEYS
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_SZ /v "" /d "Open with Sublime Text 3"   /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3"         /t REG_EXPAND_SZ /v "Icon" /d "%sublimeTextPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%sublimeTextPath% \"%%1\"" /f

pause

You just need to copy above code into the text editor you like and save it as a batch file. Note, please change the sublimeTextPath to the sublime_text.exe on your system. Then, what you need to do is right click on the batch file you saved and "Run as administrator" and it should show below:

This means you have successfully added Sublime Text to your context menu. Then you can verify this by right clicking on any text file and you should see below:

Please note that you need to run the batch file as administrator, otherwise you will see errors on the command line console.

Vim: Save file in read-only mode without restart your work

Open a file as normal, forgetting to use “sudo”, and therefore viewing a read-only file.

Then mistakenly try to edit the read-only file in the traditional manner.

:w !sudo tee%

At this point we will be presented with the content of the file and a prompt to press ENTER or type another command.

To simply save the file and move on we just press ENTER, and then press the letter “O” (oh).

(NOTE: “L” seems to do pretty much the same thing.)

The file will be saved but remains open in vi/vim for more editing or reading.

We can now exit normally by typing “:q!” since the file is still open as “read-only”.

What the command does:
:w = Write a file.
!sudo = Call shell sudo command.
tee = The output of the vi/vim write command is redirected using tee.
% = Triggers the use of the current filename.
Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.

向远方出发

如此的相信无论什么都能做到

如此的想要相信无论什么都能做到

却开始意识到那是不可能的

感觉被什么无形的东西所左右着

想着要做些什么,不做些什么不行

但是,却不知道到底该如何是好

因此…向远方出发…

Fedora彻底移除Nvidia显卡驱动,以及恢复开源Nouveau驱动

我首先提倡一种思维模式,就是用小白的眼光去看“高深”的问题!

在Fedora中安装Nvidia显卡驱动方法有很多:

  1. 到Nvidia官网下载官方驱动并安装。
  2. 使用第三方源中的软件包。
  3. 使用Bumblebee
    Bumblebee是为解决双显卡切换问题而存在的一个开源产品

不幸的是以上三种方法安装之后,均出现同样失败的结局。