免费写shell脚本,和发布自己用的脚本!【长期有效!】【2014-11-24更新】

sh/bash/dash/ksh/zsh等Shell脚本
头像
royclark
帖子: 301
注册时间: 2011-05-15 1:01
系统: Debian GNU/Linux sid

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#16

帖子 royclark » 2013-09-13 22:14

onlylove 写了:
瓦特1 写了:
onlylove 写了:
瓦特1 写了:synclient VertEdgeScroll=1 HorizEdgeScroll=1
开机启动 谢谢
触摸板的滚动啊……这个有专门的配置文件的…… :em20
~/.profile没效
在.bashrc加
synclient VertEdgeScroll=1 HorizEdgeScroll=1
重启后
要启动终端才有效
我是13.10没etc/x11/xorg.conf
配置文件在那里



删了办公和游戏 ,启动应用程序 启动不了 不知道有没有关联
还真不在/etc/X11/xorg.conf里面……
印象里面是/usr/share或者别的目录里
在 /etc/X11/xorg.conf.d/ 里建个文件写进去就好了,比如说像这样。

代码: 全选

$ cat /etc/X11/xorg.conf.d/synaptics.conf 
Section "InputClass"
        Identifier      "Touchpad"                      # required
        MatchIsTouchpad "yes"                           # required
        Driver          "synaptics"                     # required
        Option          "TapButton1"            "1"
        Option          "RightEdge"             "5550"
        Option          "VertEdgeScroll"        "1"
        Option          "HorizEdgeScroll"       "1"
        Option          "RTCornerButton"        "2"     # browser "back" btn
        Option          "RBCornerButton"        "3"     # browser "forward" btn
EndSection
这是参照 https://wiki.debian.org/SynapticsTouchpad 设的,在本人 Debian Sid 上有效。要是参照 https://wiki.archlinux.org/index.php/Touchpad_Synaptics 设置应该也可以。
另外,不清楚 Ubuntu 13.10 上有没有下面这样的东西,有的话应该也能起作用。
gnome-control-center.png
onlylove
论坛版主
帖子: 5371
注册时间: 2007-01-14 16:23

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#17

帖子 onlylove » 2013-09-14 0:47

royclark 写了:
onlylove 写了:
瓦特1 写了:
onlylove 写了:
瓦特1 写了:synclient VertEdgeScroll=1 HorizEdgeScroll=1
开机启动 谢谢
触摸板的滚动啊……这个有专门的配置文件的…… :em20
~/.profile没效
在.bashrc加
synclient VertEdgeScroll=1 HorizEdgeScroll=1
重启后
要启动终端才有效
我是13.10没etc/x11/xorg.conf
配置文件在那里



删了办公和游戏 ,启动应用程序 启动不了 不知道有没有关联
还真不在/etc/X11/xorg.conf里面……
印象里面是/usr/share或者别的目录里
在 /etc/X11/xorg.conf.d/ 里建个文件写进去就好了,比如说像这样。

代码: 全选

$ cat /etc/X11/xorg.conf.d/synaptics.conf 
Section "InputClass"
        Identifier      "Touchpad"                      # required
        MatchIsTouchpad "yes"                           # required
        Driver          "synaptics"                     # required
        Option          "TapButton1"            "1"
        Option          "RightEdge"             "5550"
        Option          "VertEdgeScroll"        "1"
        Option          "HorizEdgeScroll"       "1"
        Option          "RTCornerButton"        "2"     # browser "back" btn
        Option          "RBCornerButton"        "3"     # browser "forward" btn
EndSection
这是参照 https://wiki.debian.org/SynapticsTouchpad 设的,在本人 Debian Sid 上有效。要是参照 https://wiki.archlinux.org/index.php/Touchpad_Synaptics 设置应该也可以。
另外,不清楚 Ubuntu 13.10 上有没有下面这样的东西,有的话应该也能起作用。
gnome-control-center.png
刚去看了下,应该是/usr/share/X11/xorg.conf.d/下面一个数字开头(我电脑上是50)加synaptics的一个文件,编辑那个文件应该就可以
#include <stdio.h>
void main()
{
double world;
unsigned letter;
short stay;
long memories;
printf("I miss you.\n");
}
头像
瓦特1
帖子: 383
注册时间: 2009-09-16 22:54

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#18

帖子 瓦特1 » 2013-09-14 2:37

onlylove 写了:
royclark 写了:
onlylove 写了:
瓦特1 写了:
onlylove 写了:
瓦特1 写了:synclient VertEdgeScroll=1 HorizEdgeScroll=1
开机启动 谢谢
触摸板的滚动啊……这个有专门的配置文件的…… :em20
~/.profile没效
在.bashrc加
synclient VertEdgeScroll=1 HorizEdgeScroll=1
重启后
要启动终端才有效
我是13.10没etc/x11/xorg.conf
配置文件在那里



删了办公和游戏 ,启动应用程序 启动不了 不知道有没有关联
还真不在/etc/X11/xorg.conf里面……
印象里面是/usr/share或者别的目录里
在 /etc/X11/xorg.conf.d/ 里建个文件写进去就好了,比如说像这样。

代码: 全选

$ cat /etc/X11/xorg.conf.d/synaptics.conf 
Section "InputClass"
        Identifier      "Touchpad"                      # required
        MatchIsTouchpad "yes"                           # required
        Driver          "synaptics"                     # required
        Option          "TapButton1"            "1"
        Option          "RightEdge"             "5550"
        Option          "VertEdgeScroll"        "1"
        Option          "HorizEdgeScroll"       "1"
        Option          "RTCornerButton"        "2"     # browser "back" btn
        Option          "RBCornerButton"        "3"     # browser "forward" btn
EndSection
这是参照 https://wiki.debian.org/SynapticsTouchpad 设的,在本人 Debian Sid 上有效。要是参照 https://wiki.archlinux.org/index.php/Touchpad_Synaptics 设置应该也可以。
另外,不清楚 Ubuntu 13.10 上有没有下面这样的东西,有的话应该也能起作用。
gnome-control-center.png
刚去看了下,应该是/usr/share/X11/xorg.conf.d/下面一个数字开头(我电脑上是50)加synaptics的一个文件,编辑那个文件应该就可以
# Example xorg.conf.d snippet that assigns the touchpad driver
# to all touchpads. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
# Additional options may be added in the form of
# Option "OptionName" "value"
#
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-t ... rrors.html
MatchDevicePath "/dev/input/event*"
EndSection

Section "InputClass"
Identifier "touchpad ignore duplicates"
MatchIsTouchpad "on"
MatchOS "Linux"
MatchDevicePath "/dev/input/mouse*"
Option "Ignore" "on"
EndSection

# This option enables the bottom right corner to be a right button on
# non-synaptics clickpads.
# This option is only interpreted by clickpads.
Section "InputClass"
Identifier "Default clickpad buttons"
MatchDriver "synaptics"
Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
# To disable the bottom edge area so the buttons only work as buttons,
# not for movement, set the AreaBottomEdge
# Option "AreaBottomEdge" "82%"
EndSection

# This option disables software buttons on Apple touchpads.
# This option is only interpreted by clickpads.
Section "InputClass"
Identifier "Disable clickpad buttons on Apple touchpads"
MatchProduct "Apple|bcm5974"
MatchDriver "synaptics"
Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
EndSection
旁边还有个51-synaptics-quirks.conf
onlylove
论坛版主
帖子: 5371
注册时间: 2007-01-14 16:23

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#19

帖子 onlylove » 2013-09-14 5:13

# Example xorg.conf.d snippet that assigns the touchpad driver
# to all touchpads. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
:em20 按照这文件的说法,你还是把这文件复制到/etc/X11/xorg.conf.d吧,或者直接在/etc/X11/xorg.conf.d里面写个新的,我回去瞅瞅我那文件里面有没有提到这么一说去
#include <stdio.h>
void main()
{
double world;
unsigned letter;
short stay;
long memories;
printf("I miss you.\n");
}
la0wei
帖子: 4
注册时间: 2013-09-14 19:53
系统: windows 7

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#20

帖子 la0wei » 2013-09-22 13:30

能帮忙把这篇文章中的指令写成脚本吗?不太懂脚本后和一条一条敲有多大的区别
头像
lxf1992521
帖子: 240
注册时间: 2011-06-26 18:28
联系:

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#21

帖子 lxf1992521 » 2013-09-23 22:42

la0wei 写了:能帮忙把这篇文章中的指令写成脚本吗?不太懂脚本后和一条一条敲有多大的区别
呃,什么文章?脚本的作用就是在于避免重复输入命令的繁琐和批量指令执行的便捷,两者确实没多大区别。

但是你要是懂得和系统相互配合,那么在Unix中基本上可以解决生产和生活中的大部分问题了,包括各种服务的搭建和备份等……
jeffkuang
帖子: 5
注册时间: 2011-03-03 15:20

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#22

帖子 jeffkuang » 2013-10-15 20:02

关注。 :em11
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#23

帖子 susbarbatus » 2013-10-15 20:21

:em09 正在折腾 wmii,有个切换 tag 的问题,自己正在写,不是什么复杂的东西,但是怎么样能比较简洁高效是个问题,楼主方便的话也可以帮我一起写一下。

我把问题抽象出来,大概是这样的:
某个目录下有若干目录,只能用一种特殊的 ls 去获得该目录下的内容,这种 ls 得到的结果是:

代码: 全选

1/
5/
abcd/
sel/
twb/
xyz/
除了 sel/ 必然存在外,其他目录名都是不一定的,但有两点是确定的:
1. 全都是目录,而且 xyz/ 的这个 / 没法去掉
2. 排列顺序是数字然后字符串,字符串按字母排序。
在 sel/ 这个目录下有一个 ctl 文件,文件内容是不包括 sel/ 在内的其他一个目录名,比如 twb,这里是不带 / 的。
现在我需要的是读取这个 sel/ctl 文件,得到这个目录名,然后根据这个目录名得到下一个目录名(不带 /,sel 目录要除外)。
比如 ctl 文件里记录的是 5 就输出 abcd,是 abcd 就输出 twb,是 xyz 就输出 1。

以上。
沉迷将棋中……
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#24

帖子 susbarbatus » 2013-10-16 10:26

楼上问题自己解决了,因为是小众需求就不贴码了,丧心病狂地用了一堆grep和cut。
沉迷将棋中……
头像
lxf1992521
帖子: 240
注册时间: 2011-06-26 18:28
联系:

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#25

帖子 lxf1992521 » 2013-10-16 13:12

susbarbatus 写了:楼上问题自己解决了,因为是小众需求就不贴码了,丧心病狂地用了一堆grep和cut。
有什么需求可以贴出来 :em11
馍饭老公
帖子: 1
注册时间: 2013-11-21 18:34
系统: ubuntu

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#26

帖子 馍饭老公 » 2013-11-21 18:48

:em06 帮忙写个能把man~info里的英文单词整理出来的脚本吧
刚接触linux~英语单词记的又少的小白求救
头像
lxf1992521
帖子: 240
注册时间: 2011-06-26 18:28
联系:

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#27

帖子 lxf1992521 » 2013-11-21 22:22

馍饭老公 写了::em06 帮忙写个能把man~info里的英文单词整理出来的脚本吧
刚接触linux~英语单词记的又少的小白求救
这个也需要整理?我也是这样过来的,说一下我的方法:

代码: 全选

man program-name > ~/program-name.man
cd ~
# 接着下载星际译王,使用文本编辑器打program-name.man文件,碰到不会的就划词查找,OK?
best1196
帖子: 3
注册时间: 2013-11-23 15:24
系统: ubuntu 10.11

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#28

帖子 best1196 » 2013-11-23 16:06

lz大神你好,有个问题想请教一下, :em76

----shell script sh1.sh---

代码: 全选

#! /bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH     
echo -e "You should input 2 integers\n" #问题代码1
read -p "first integer:" first
read -p "second integer:" second
total=$(($first * $second))
echo -e "\nThe result is : $total"  #问题代码2
----shell script sh1.sh----------

我的linux是ubuntu 10.11,执行sh sh1.sh如下:

-e You should input 2 integers

first integer:2
second integer:6
-e
The result is : 12

echo完了之后参数-e也跟着输出来了,我现在想不想将这个-e显示,有什么方法吗?
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#29

帖子 susbarbatus » 2013-11-23 17:30

best1196 写了:lz大神你好,有个问题想请教一下, :em76

----shell script sh1.sh---

代码: 全选

#! /bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH     
echo -e "You should input 2 integers\n" #问题代码1
read -p "first integer:" first
read -p "second integer:" second
total=$(($first * $second))
echo -e "\nThe result is : $total"  #问题代码2
----shell script sh1.sh----------

我的linux是ubuntu 10.11,执行sh sh1.sh如下:

-e You should input 2 integers

first integer:2
second integer:6
-e
The result is : 12

echo完了之后参数-e也跟着输出来了,我现在想不想将这个-e显示,有什么方法吗?
直接拷下来跑了一下,没这种问题……
你的 sh 是什么版本……
试试用 bash sh1.sh
沉迷将棋中……
best1196
帖子: 3
注册时间: 2013-11-23 15:24
系统: ubuntu 10.11

Re: 免费写shell脚本,和发布自己用的脚本!【长期有效!】

#30

帖子 best1196 » 2013-11-23 19:45

susbarbatus 写了:
best1196 写了:lz大神你好,有个问题想请教一下, :em76

----shell script sh1.sh---

代码: 全选

#! /bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH     
echo -e "You should input 2 integers\n" #问题代码1
read -p "first integer:" first
read -p "second integer:" second
total=$(($first * $second))
echo -e "\nThe result is : $total"  #问题代码2
----shell script sh1.sh----------

我的linux是ubuntu 10.11,执行sh sh1.sh如下:

-e You should input 2 integers

first integer:2
second integer:6
-e
The result is : 12

echo完了之后参数-e也跟着输出来了,我现在想不想将这个-e显示,有什么方法吗?
直接拷下来跑了一下,没这种问题……
你的 sh 是什么版本……
试试用 bash sh1.sh
----------------------------------------------------------------
用bash sh1.sh 确实可以用,但是用 sh sh1.sh 还是不能。
至于你说的查看sh 的版本,我不知道怎么查,但我把 /bin/ 下的一些文件找出来了。

----------------------------------------
root@yx:/tmp/script# ls -l /bin/*sh
-rwxr-xr-x 1 root root 916692 2011-05-18 17:54 /bin/bash
-rwxr-xr-x 1 root root 96188 2011-05-03 23:01 /bin/dash
lrwxrwxrwx 1 root root 4 2013-07-31 14:37 /bin/rbash -> bash
lrwxrwxrwx 1 root root 4 2013-07-31 14:37 /bin/sh -> dash
lrwxrwxrwx 1 root root 7 2013-07-31 14:37 /bin/static-sh -> busybox
---------------------------------------------------------------------------------------------
sh 连接到 dash 去了,难怪会这样。
多谢。 :em42
回复