由买买提看人间百态

topics

全部话题 - 话题: basename
1 (共1页)
H********g
发帖数: 43926
1
升级版,可以读取命令行输入了
#csv2xls.pl
#>csv2xls.pl abcd.csv
#generages abcd.xls
use strict;
use warnings;
use Text::CSV;
use Spreadsheet::WriteExcel;
my $infile="test.csv" ;
if($ARGV[0]){$infile=$ARGV[0];}
my $basename=$infile;
$basename=~s/.csv//i;
my $outfile="$basename.xls";
my @rows;
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, "<:encoding(utf8)", $infile or die "$infile: $!";
my $rowcount=... 阅读全帖
s***k
发帖数: 23
2
【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: stock (Microsoft is dead), 信区: Programming
标 题: Perl for programmers(12): Standard file modules
发信站: The unknown SPACE (Fri May 26 14:51:03 2000) WWW-POST
use File::Basename;
($name,$path,$suffix) = fileparse($fullname,@suffixlist);
fileparse_set_fstype($os_string); "VMS" "MSDOS" or MacOS";
$basename = basename($fullname,@suffixlist);
$dirname = dirname($fullname);
use File::Copy;
copy $src_file, $dst_file;
copy SRC_FILE,DST_FILE;
$fh = FileHandle->new("an
s***g
发帖数: 495
3
来自主题: Hardware版 - 如何备份可启动的 USB Drive?
(%73)(20:49)(pong)~/ws> sudo cat /root/bin/dump_root
#!/bin/sh
if [ $# -ne 1 -a $# -ne 2 ] || [ ! -b $1 ]; then
echo "`basename $0` [hostname]"
else
_T=ext3
umount ${1}1
echo "`basename $0` on `date '+%Y_%m_%d'` to $1 $2" >> /root/bin/log
&& \
dd if=/dev/zero of=$1 bs=1M count=1 && \
sync && sync && sync && \
parted $1 --script mklabel msdos && \
parted $1 --script mkpart primary $_T 2048s -- -1 && \
... 阅读全帖
s***g
发帖数: 495
4
(07:16)(root@ping)~/bin> cat sync_home
#!/bin/sh
if [ $# -ne 1 -a $# -ne 2 ] || [ ! -b $1 ]; then
echo "`basename $0` [/home]"
else
_T=ext4
umount ${1}1
echo "`basename $0` on `date '+%Y_%m_%d'` to $1 $2" >> /root/bin/log
&& \
dd if=/dev/zero of=$1 bs=1M count=1 && \
sync && sync && sync && \
parted $1 --script mklabel gpt && \
parted $1 --script mkpart primary $_T 2048s -- -1 && \
mkfs.$_T -L HO... 阅读全帖
s***g
发帖数: 495
5
来自主题: Hardware版 - pogoplug可靠性如何?
My script to backup your rootfs.
I use it to backup my rootfs on a 2G USB stick and transfer my rootfs to a
NSA320 from POGO E02.
(%3)(21:40)(punk)~> sudo cat /root/bin/dumpdisk
#!/bin/sh
if [ $# -ne 1 -a $# -ne 2 ] || [ ! -b $1 ]; then
echo "`basename $0` [hostname]"
else
_T=ext3
umount ${1}1
echo "`basename $0` on `date '+%Y_%m_%d'` to $1 $2" >> /root/bin/log
&& \
dd if=/dev/zero of=$1 bs=1M count=1 && \
sync && sync ... 阅读全帖
g****e
发帖数: 172
6
那些suspicious files安全吗?
多谢!!
sudo chkrootkit
ROOTDIR is `/'
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... not infected
Checking `cron'... not infected
Checking ... 阅读全帖
b******n
发帖数: 592
7
File::Basename;
then use basename
g****e
发帖数: 172
8
【 以下文字转载自 Linux 讨论区 】
发信人: gangle (nothing), 信区: Linux
标 题: 请高手帮忙看看这个chkrootkit安全否?
发信站: BBS 未名空间站 (Mon Aug 13 18:29:14 2012, 美东)
那些suspicious files安全吗?
多谢!!
sudo chkrootkit
ROOTDIR is `/'
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... ... 阅读全帖
m*****e
发帖数: 4193
9

"dirname $filename" returns the pathname
"basename $pathname" returns the last pathname
input: FILENAME
PATHNAME=`dirname $FILENAME`
BASEDIR=`basename $PATHNAME`
echo "${FILENAME}_${BASEDIR}"
f***o
发帖数: 92
10
#!/usr/bin/perl


use File::Basename;


my $filename = "/nfs/sc/proj/jkt/jkt088/jmeng/jkt/FRZ1/rcbgfctls_frz1_ww43.3
";


print dirname($filename) . "\n";
split(/_/, basename($filename));
print $_[0] . "\n";
a*p
发帖数: 62
11
my php:
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize($processfilename));
header("Content-Disposition: attachment;
filename=".basename($processfilename));
readfile($processfilename);
My experiences is IE is not as capable as Netscape in
handling octet-stream
this code probably doesn't work in IE5.5
you can use NetXRay to detect what's going on if you click
attachment in webmail
or you can check HTTP RFC for exact answer.
Unfortunately as far as I know, ther
E**a
发帖数: 275
12
来自主题: Hardware版 - PogoPlug安装Dropbox攻略(部分原创)
初衷:原本想用pogoplug架个surveillance webcam,然后把video stream和snapshots
自动上传到dropbox(之所以用dropbox,是因为这个不需要安装客户端,其他的软件俺
暂时没找到解决方案). 用lsusb和hwinfo都能看到我的6年老的logitech quickcam pro
for notebook,但motion始终无法打开/dev/video0,用ls /dev/video*查看竟然无
video device,真tm奇怪。
下面姑且把dropbox搞定:
1. 下载dropbox_uploader的bash script(这个非原创,非常赞的script)
https://github.com/andreafabrizi/Dropbox-Uploader
这个bash script不需要你的dropbox的账号密码
2. 解压上传到Pogoplug里某个文件夹,e.g., /mnt/DropboxUl,其中包含Readme和
dropbox_uploader.sh
3. 首次运行并设置Dropbox帐号关联:
-------... 阅读全帖
e*c
发帖数: 642
13
来自主题: Linux版 - 一个简单的bash脚本怎么写?
#!/bin/bash
for rmfl in `ls *.rmvb`; do
flnm=`basename $rmfl`
mencoder ... $rmfl ... $flnm.avi
done
save in a file, chmod u+x, run.

01
t*****g
发帖数: 1275
14
${0##*/} is to get the basename of the script.
h****g
发帖数: 772
15
http://www.tutorialspoint.com/python/python_cgi_programming.htm 'filename'
系统是debian squeeze, python 2.6.6, apache2
错误信息如下
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537,
in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229,
in _process_target
result = _execut... 阅读全帖
d****n
发帖数: 1637
16
来自主题: Linux版 - ask one command in ubuntu
for i in F1/*
do
bname=`basename $i`
if [ ! -f F2/$bname ]
then
cp $i destination/
fi
done

files
and
another
i***r
发帖数: 1035
17
来自主题: Linux版 - 这个command 是什么意思?
q2=`cd `dirname $3`; pwd`/`basename $3`
请问谁能帮我break down一下?
多谢
l*******G
发帖数: 1191
18
The following works :
#!/bin/bash
filename=`basename $0`
echo "script name is:" $filename
s*******n
发帖数: 38
19
来自主题: Programming版 - 同主题转寄 (转载)
写了个同主题转寄的python script. 就是附件还不work. mitbbs的附件bs直接pass.
python新手。边学边编的。
----------------------------------------------
from urllib import request
from bs4 import BeautifulSoup, NavigableString
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
from email.header import Header
#password=sys.argv[1]
password='*****'
address='http://www.mitbbs.com/article_t/Programming/17234582.html'
urlBase='http://www.m... 阅读全帖
d****n
发帖数: 1637
20
来自主题: Programming版 - gcc compile option
in Makefile
you can do
obj/%.o: src/%.c
[ Tab here ]gcc $(CFLAGS) -c $? -o $@
also you can do it in linux shell
mkdir -p obj
for i in *c; do gcc -c $i -o obj/`basename $i|sed 's/.c$/.o/g'`;done
d****n
发帖数: 1637
21
来自主题: Programming版 - 问个临时抱佛脚的问题 (转载)
1. find a file by name/pattern
2. find a exact word/pattern in text file, counters of this pattern/word.
exclude this word/pattern in this file and do the same
3. sort a table(numbers) print unique counts by x column.
4. replace/insert/delete pattern/word in a text file.
5. rename/move/copy files from prefix/suffix "xxx" to "yyy"
6. given a table with numbers, calculate the average/sum/stdv at column x,y
,z
7. how/how many ways to detach a process when the process is running? before
it starts?... 阅读全帖
h******a
发帖数: 198
22
now I could only think up one way:
foreach file(*.cpp)
mv $file `basename $file .cpp`.C
end
for tcsh/csh
a***n
发帖数: 262
23
#!/bin/sh -xv
#To get little hints please delete -xv flags
#remove first three lines of everyfile in current directory
#except the shell program
for file in `ls`
do
if ( test -f $file && test $file != `basename $0` )
then
sed 1,3d $file > $file.tmp
mv $file.tmp $file
else
echo "$0: $file can't be changed" 1>&2
fi
done
j***n
发帖数: 9
24
来自主题: Unix版 - Shell Question
Thanks, guys, here is another solution
#!/bin/ksh
namein=$1
basein=`basename ${namein}` #the baseline command will
remove the path
nameout=${basein%.cfg}
echo $nameout
It is really cool to have so may High-hands here.
s*****v
发帖数: 360
25
for f in *.jpg; do mv $f `basename $f .jpg`.JPG; done
x***o
发帖数: 2
26
来自主题: Unix版 - How to use file modifiers in bash/sh
In csh/tcsh scripts, I use
set basename = $1:r
to obtain the root name of $1.
What's the equivalent in sh/bash scripts?
Thanks.
q*z
发帖数: 13362
27
来自主题: Unix版 - A simple question!

the
in alldata dir
find .. -name 'dir*.txt'-printf 'ln -s %p `basename %p`'|sh
j**********p
发帖数: 22
28
for f in /path_in/IBM.csv /path_in/DELL.csv; do
perl test.pl $f >/path_out/`basename $f`.out
done
E******g
发帖数: 170
29
for i in *.png; do
b=`basename $i`
convert -units PixelsPerInch $i -density 300 ${b}_new.png
done
1 (共1页)