a**********0 发帖数: 422 | 1 The Unix Commands
其实就是攒了一下网上的资料
# Create a new tar archive.
# the folder dirname/ is compressed into archive_name.tar
tar cvf archive_name.tar dirname/
# Extract from an existing tar archive
tar xvf archive_name.tar
# View an existing tar archive
tar tvf archive_name.tar
# Search for a given string in a file (case in-sensitive search).
grep -i "the" demo_file
# Print the matched line, along with the 3 lines after it.
grep -A 3 -i "example" demo_text
# Search for a given string in all files recur... 阅读全帖 |
|
p**h 发帖数: 99 | 2 【 以下文字转载自 Linux 讨论区 】
【 原文由 penh 所发表 】
假设我有2目录, 里面的相同文件名的内容应该是完全相同的.
比如:
在dir1中, 我有: file1 file2 file3...
在dir2中, 我有: file1 file2 file3...
dir1/file1 应该和 dir2/file1 完全相同.
dir1/file2 应该和 dir2/file2 完全相同.
dir1/file3 应该和 dir2/file3 完全相同.
...
如何进行比较以确认这一点? 当然我可以用diff手动地一个个地比较.
但有没有更cool的办法? thanks. |
|
p******f 发帖数: 162 | 3
let's say file1 & file2 are in directory ~user0/secret,
and if ~user0, ~user1 & ~user2 are in a single filesystem
you may try this:
user0$ chmod 711 ~ ~/secret
user0$ chmod 644 ~/secret/{file1,file2}
user1$ mkdir ~/secret
user1$ chmod 700 ~/secret
user1$ ln ~user0/secret/{file1,file2} ~/secret
same thing for user2
user0$ chmod 700 ~ (optional)
user0$ chmod 700 ~/secret
user0$ chmod 666 ~/secret/{file1,file2} |
|
i*****e 发帖数: 113 | 4 1) open file2 with rw
2) set file2 size to length of file1, and lseek to eof
3) read a block (2k or 4k, i.e. one page) from file1
4) reverse the bits on the block
5) find proper place and write back to file2
6) if not done, go to 3) |
|
j****c 发帖数: 19908 | 5 我原有 file1.txt 和 file2.txt,我刚才误操作
cp file1.txt file2.txt
结果把原先的file2.txt覆盖掉了,能恢复吗? |
|
d****n 发帖数: 1637 | 6 in vim
:badd file1.txt
:badd file2.txt
:vs
:b2
//split windows now, file2.txt in left window and file1.txt in right window
:diffthis
control+W
//type control +W twice , switch to right window now
:diffthis
OR just :
vimdiff file1.txt file2.txt
gg |
|
i***e 发帖数: 3219 | 7 well, what i want to do is this:
if ["file1 in local machine" newer than "file2 in remote machine"]; then
scp -p file1 me@remote_machine:file2
else
scp -p me@remote_machine:file2 file1
fi
so, how to implement the test of condition? thanks! |
|
D******n 发帖数: 2836 | 8 People are crazy in our company..
ex1: File2 includes file1. File1 has a "%macro xxx" but it does not have
"%mend", turned out it is in file2 while file2 has many macros too.
ex2: macros inside a macro...wtf....
other stuffs, no indents, no comments... |
|
m******4 发帖数: 26 | 9 Thanks first!
I have two RAW files:
file1: file2:
id id name
101 101 a
102 110 b
103 102 c
... 112 d
103 e
I only want to READ IN the data in raw file2 which are matched by id in raw
file1,i.e.
id name
101 a
102 c
103 e
Important: 1.these are raw files, not SAS data sets
2.I do not want to read in all records from file2
because it is too large. |
|
f**********t 发帖数: 1001 | 10 抛砖,我的2 cent.
基本思路:用hash和MD5。
1. 把大文件file1里的每一行做MD5。重复行的MD5会相同。把所有(line, MD5 value)
写入另一个文件file2。
2. 可能另一个文件file2特别大,不能一次读入内存。这时可以把它分成若干个小的。
比如我们想把它分成8个小的,则根据MD5 value的后三位,分到第0,1,2,。。。7个
文件。这时重复的行一定在相同的小文件中。
3. 这8个文件都可以一次读入内存。对于每个文件:
count重复的行,可用map/hashmap数据结构。(8个文件中,重复的行一定不会跨越
两个文件)。把所有重复的行写入文件file3
4. 根据file1和file3,去掉所有重复的行。把不重复的写入fileDst。
呼唤更好的解法 =) |
|
q******n 发帖数: 66 | 11 Is this what you are trying to do?
-bash-3.2$ cat file1
1_1 1_2 1_3 1_4
-bash-3.2$ cat file2
2_1 2_2 2_3 2_4
-bash-3.2$ cut -f3,4 file2 > file3
-bash-3.2$ paste file1 file3 > file4
-bash-3.2$ cat file4
1_1 1_2 1_3 1_4 2_3 2_4 |
|
l**n 发帖数: 7272 | 12 虽然这里的码工比较少,但是能appreciate coding和programming的朋友也可以看看。
我觉得挺有意思的。
http://blog.sina.com.cn/s/blog_5d90e82f01014k5j.html
我想通过这篇文章解释一下我对 Unix 哲学本质的理解。我虽然指出 Unix 的一个设计
问题,但目的并不是打击人们对 Unix 的兴趣。虽然 Unix 在基础概念上有一个挺严重
的问题,但是经过多年的发展之后,这个问题恐怕已经被各种别的因素所弥补(比如大
量的人力)。但是如果开始正视这个问题,我们也许就可以缓慢的改善系统的结构,从
而使得它用起来更加高效,方便和安全,那又未尝不可。同时也希望这里对 Unix 命令
本质的阐述能帮助人迅速的掌握 Unix,灵活的应用它的潜力,避免它的缺点。
通常所说的“Unix哲学”包括以下三条原则[Mcllroy]:
一个程序只做一件事情,并且把它做好。
程序之间能够协同工作。
程序处理文本流,因为它是一个通用的接口。
这三条原则当中,前两条其实早于 Unix 就已经存在,它们描述的其实是程序设计最... 阅读全帖 |
|
j***n 发帖数: 301 | 13 Hi all,
I'm trying to take advantage of http compression / decompression feature men
tioned in RFC2616.
I have created two gziped files using unix gzip command: file1 and file2.
I deployed them to tomcat and wrote a simple program to set the appropriate
http header. In FF or IE the file can be browsed as regular page without run
time compression overhead at serverside.
When I concatenated file1 and file2 into one file, I was still able to decom
press them using Unix gzip command. What I got is a |
|
h***a 发帖数: 358 | 14 我在access2000 中建立了一个tree view
+....folder1
-.....folder2
......file1
......file2
....folder3
+表示有东西,可以expand, -表示已经expand 了, 没有child 的话,
就没有任何加+,-好。
我现在要求得到这样的结果。
+, - 继续要所表达的意思。 但是在根目录下, 可以区分是不同的level的node.
列如, 根目录下可以有file, 有folder, 但是我不知道怎么用符号或者 image把他们给
区分开
+....folder1
-.....folder2
......file1
......file2
....folder3
....file3
就象建立folder 和file 一样。 一看就知道是文件夹还是文件, 是空文件夹,还是有东
西
请问有人知道access 里面怎么做吗? 用access 的VBA也行. 多谢 |
|
y********o 发帖数: 2565 | 15 查了本版历史,有的尽是有关Swing应用程序显示中文的问题,与我这个关系不大。
好长时间已经没有碰过Java了。
我要从一个纯文本文件file1.txt中将某些汉字逐个读出,并逐个写入文件file2.txt中。
写了如下的几行,只尝试读写一个汉字,不成功:
FileInputStream fis = new FileInputStream("file1.txt");
InputStreamReader isr = new java.io.InputStreamReader(fis, "GB2312");
FileOutputStream fos = new FileOutputStream("file2.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos, "GB2312");
我不懂怎样读出汉字。
如果我用isr.read()并将其返回结果System.out.println出来的话,屏幕只会显示一个数
字25105, 这个数字应当是file1.txt的第一个汉字“我”了。怎样让它println出汉 |
|
p*****s 发帖数: 344 | 16 just some thoughts, never tried myself
1. you call "exe with -i file1 -j file2 ..." first. Assume the return
process id is , ls /proc//fd/
you should file some fd nums (
2. by default /proc//1, 2, 3 are your pipe fd
3. use gdb attach to the process
4. use dup2(,) to swap fd so that your exe can read
from pipe |
|
k****s 发帖数: 162 | 17 试过 cp -r /user/file1/ /user/file2/
结果就会把file1这个目录整个拷贝到file2里面,我不想要file1这个目录名,请指点
,谢谢~ |
|
p*****a 发帖数: 1152 | 18 http://linuxcommando.blogspot.com/2008/09/how-to-find-and-delete-all-hard-links.html
Deleting a file is deceptively simple. You can simply use the rm command
like this.
$ rm file1
However, if the file has one or more hard links to it, life gets more
interesting. You need to seek and destroy all hard links to the file.
A hard link is essentially another name for a file. Hard links to file1 can
be created as follows:
$ ln file1 file2
$ ln file1 tmp/file3
file2 and file3 become another name of file |
|
o**n 发帖数: 1249 | 19 对于linux的文件权限管理,是一个文件只能属于一个group么,如果我要做这样一个类
似的事情怎么办?
user group
file1 rwxrwx--- user1 group1
file2 rwxrwx--- user2 group2
我想让另外一个user3可以访问file1和file2,就做不到是么?除非把group1和group2
换成用一个group?我是想如果一个文件可以属于多个group,就灵活多了。否则对于
user和group多而且文件权限结构复杂的服务器,岂不是很麻烦?我没有这方面的经验
,欢迎指教。 |
|
a*******e 发帖数: 3021 | 20 一个目录下全是.NEF文件,
我要用一个命令转换成jpg,
exiftool -b -JpgFromRaw file1.NEF > file1.jpg
exiftool -b -JpgFromRaw file2.NEF > file2.jpg
咋写个命令行一下就行了?谢谢 :) |
|
z***l 发帖数: 256 | 21 请教大家一个问题 我现在有两个二进制文件 是由同一个程序在两台不同的机器上产
生的 这两台机器都是UNIX 但configuration不一样 用diff file1 file2, 结果是
file1 and file2 are different 请问有没有办法知道这两个二进制文件是哪些的
bytes不同呢? |
|
F****3 发帖数: 1504 | 22 请问怎么看真实进程?我在用gzip来zip我的一个目录架的时候,其他用户能够看到
gzip正在处理那个文件吗?比如
gzip abc_folder
里面有
file1
file2
file3
别人能看到file1,file2, file3的文件名吗?
谢谢! |
|
O******e 发帖数: 734 | 23 Maybe this is more like what you want:
$ tar tf p1.tar
file1
file2
$ tar tf p2.tar
file3
file4
$ tar Af p.tar p1.tar
$ tar Af p.tar p2.tar
$ tar tf p.tar
file1
file2
file3
file4
It seems that the "tar Af" command needs to be issued once
for each of p1 and p2. I didn't play around with the gzip
part; you can try it on your own. |
|
d*o 发帖数: 108 | 24 我知道
$yyy = anything;
$replace = “sed `s/XXX/$yyy/g` file1 > file2;
但在下面的 “.” 甚摸意思呢? (结果是一样的. Code written by someone else)
$yyy = anything;
$replace = “sed `”.”s/XXX/”.$yyy.”/g` file1 > file2; |
|
c**t 发帖数: 2744 | 25 +
我知道
$yyy = anything;
$replace = “sed `s/XXX/$yyy/g` file1 > file2;
但在下面的 “.” 甚摸意思呢? (结果是一样的. Code written by someone else)
$yyy = anything;
$replace = “sed `”.”s/XXX/”.$yyy.”/g` file1 > file2; |
|
b***y 发帖数: 2799 | 26 ☆─────────────────────────────────────☆
shuo (说说罢了) 于 (Thu Sep 22 16:28:10 2005) 提到:
其实是很简单的问题。 两个file,一个file有 node1 node2 C 三个field。另一个
file是个lookup table有 node E F三个field。输出是, node1 node2 C E(node1
) F(node1) E(node2) F(node2). 就是为node1,2找对应的E, F然后全部输出的意思
。 可是我不太会写程序,只能写最简单最笨的。 所以我写乐下边这个。 都还没管node2
, 想着先把node1 得E,F输出出来到一个out.txt里边,然后在运行一遍给node2找对应的E
, F。可是因为我的file1很大,几十万条record。 这个程序运行了2个小时乐,才1/5多
点。 可能也是file I/O的问题。 可是如果我不开关file2, 我不知道怎么让file2的
ifstream指针回到文件最顶上。 结果就是他只查找一遍,然 |
|
s****c 发帖数: 299 | 27 I was trying to write a large list to a file. But the file is always missing
a couple of lines at the bottom. If I print the list, every line is there.
It felt like the writelines method didn't get finished before the next
command got run. I inserted a sleep but still no help.
Could any one point out what is wrong with my code? Thanks.
file2=open(logfile, 'w')
file2.writelines(OS) #Always missing a couple of lines in the file
time.sleep(5)
print OS #But when i print it out |
|
S*********g 发帖数: 5298 | 28 Not possible in matlab.
you can't have a variable that is 3D while a(1,:,:) has difference size than
a(2,:,:).
However, you can attack this using structure.
a.file1 = (all data in file1 as a 2D array);
a.file2 = (all dall in file2 as a 2D array);
If your data are just a rows of number, why not use matlab's function to
load the whole file into one 2D array ocne for all?
If you can't use matlab's function, only you can tell how to determine you
hit the end of the file. No one else can answer your |
|
a***y 发帖数: 2803 | 29 opt.test.xxx.data=some data
opt.test.xxx.dim.x=some data
opt.test.xxx.dim.y=some data
opt.test.xxx.dim.z=some data
opt.test.xxx.length=some data
opt.test.xxx.tree=some data
用了
grep '\.roi\.' file1 > file2 之后,在file2里面不就只剩下
test.xxx
test.xxx.dim
了吗? |
|
r**********p 发帖数: 2 | 30 My question is:
for file1 in ./tmp/*
do
{将字符串 file1 中的所有字符a替换成xyz得到字符串 file2}
cp myfile $file2
done
请问{}中的功能如何用unix命令实现(用C很简单,但我想知道用
unix如何做? |
|
j***y 发帖数: 87 | 31 ls -t file1 file2
output:
the first file is newer
or ls -rt file1 file2
output:
the first file is older |
|
t*******l 发帖数: 421 | 32 比如在每个目录里有个子目录,其中包括一个文件含有我需要的信息。
$ ls
dir1 dir2 dir3
$ ls dir1
file1
$ more file1
user name: mary england
$ ls dir2
file2
$ more file2
user name: jon hotland
... ...
如果我想写个script,运行后会从第一到第三个目录自动找到user name,
用foreach file (*)语句后,却只读了第一个dir1,没有接着做dir2,dir3.
请帮我提示一下。多谢。 |
|
a***u 发帖数: 14 | 33 I ran the following:
>aa=$(ls -1)
>echo $aa
file1 file2
>echo "$aa"
file1
file2
Why in the case of double quote, files are printed one per line? |
|
V*****y 发帖数: 26 | 34 Hello everyone,
I encountered a 2GB limit file size problem recently. The OS is solaris 9,
according to the references I read, it should support writing to files > 2GB.
But somehow when I tried to write to a file > 2GB in my program written in
C++, the system gave me a bus error. However, I tried to concatenate two files
each with a size slightly < 2GB, it worked. I mean suppose I have two files,
file1 and file2. I issued the following command:
cat file1 file2 > newfile
And the newfile was creat |
|
f*******n 发帖数: 4 | 35 I have two file, file1 and file2.
the content of file1 is:
a1 b1
a2 b2
a3 b3
and the content of file2 is:
a1 c1
a2 c2
a3 c3
How to write a shell script to obtain a file with data look like:
a1 b1 c1
a2 b2 c2
a3 b3 c3
Thanks in advance |
|
l**********n 发帖数: 5272 | 36 In unix I can use something like cat file1 >> file2.
In windows, is there any command to append the content of file1 to file2 ?
Thanks a lot. |
|
a********h 发帖数: 245 | 37 我觉得你这个像是tag count file (参考 GBS pipeline)。
自己用 linux shell commands will do that (假设你的文件是space delimit):
cat input.txt | nl | gawk -F' ' '{print ">"$1"_"$3"\n"$2}'
>1_2
ACAAACGACTCTCGGCAACGGTTGT
>2_1
ATATGAAGACAAGTAGTGCAGCTCGGAGACGGG
>3_1
ATAATAGAGGTTTTGCAAAACAAT
sequence ID will be unique if you only have one file and also include read
number information. For multiple files, just do: cat file1 file2 file2 | nl
| gawk -F' ' '{print ">"$1"_"$3"\n"$2}' |
|
h******s 发帖数: 3420 | 38 有两个文件
file1 按 id 和 date 列出病人的event
Id. Event_date
001. 02/11/1977
001. 03/08/1977
001. 07/11/1978
001. 02/05/1979
002. 04/06/1977
002. 03/09/1978
002. 04/11/1978
..........
File2 按id和date 列出病人的admission date
Id. Admission_date
001. 02/11/1977
001. 07/11/1978
002. 04/06/1977
......
请问怎样从file2 中找到file1 event 对应的admission date?
希望输出为:
Id. Event_date. Admission_date
001. 02/11/1977. 02/11/... 阅读全帖 |
|
d******a 发帖数: 32122 | 39 【 以下文字转载自 PDA 讨论区 】
发信人: weidong (伊拉克学习小组副组长), 信区: PDA
标 题: Re: 被SKYDRIVE震精了.
发信站: BBS 未名空间站 (Sun Mar 3 15:48:18 2013, 美东)
映射表你可以看看,
Due to the limitations of the supported zip file format, the following file(
s) had to be renamed.
Original File Name -> New File Name
1.电子书目录/文件索引.txt -> 1/File1.txt
婚恋。两性/B/性社会学.epub -> 2/B/File2.epub
婚恋。两性/B/魔鬼搭讪学 1.epub -> 2/B/File3.epub
婚恋。两性/B/男性保健.epub -> 2/B/File4.epub
婚恋。两性/B/魔鬼搭讪学.epub -> 2/B/File5.epub
婚恋。两性/B/把妹达人.epub -> 2/B/File6.epub
婚恋。两性/B/骄傲风趣... 阅读全帖 |
|
q*****i 发帖数: 100 | 40 起诉一家美国连锁的修车公司,我去的这一家实在太烂了。但是本人人品和气场也不够
,在法官(small claim)面前没有当场戳穿车行前台小混混的撒谎吹牛伎俩。下面贴上
法庭呈堂描述。相关的证据都是很strong的,最终是无奈小混混将法官的注意力转移到
技术细节,我无法给出有力证据。输了,发此一贴,纪念一下,随便提醒各位为了钱包
,远离这个车行很那帮奸诈之人。
On 10/19/2011, I went to the Midas store (376 Highway #18 North East
Brunswick, NJ 08816) for oil change with a coupon which is $21.99 for pure
oil change. I was waiting there for the oil change works done. However,
around half a hour then, a staff in their store bring me to the workshop,
and show me lots of problems ... 阅读全帖 |
|
p********7 发帖数: 549 | 41 先把可以用的内存分成5部分,每个部分占用Km空间。
先把数据读入M1并且从2头到中间来判断
M1满了,存M2,并且M1从头开始,M2从尾开始判断
M2满了,存M3.新的数据继续读到M3.
M3满了,就把M2存到file1.然后新的数据读到M2.
M2满了,就把M3存file2,读新的数据到M3.
如果M1,和M2,M3的数据都没问题,需要读file的文件继续判断,就把需要的file读到
M4,M5
file的数序是从2头到中间。 |
|
d********w 发帖数: 363 | 42 http://geeksforgeeks.org/forum/topic/google-interview-question-
software-engineerdeveloper-about-algorithms-15
There is a file system on the disc. the disc has many sectors. Always
the first sector has the information about all the files.
A file data is divided into sectors. Each sector can have data from a
single file.
Each sector has 2 parts, data and the pointer to the next sector of the
file. Every last sector in the file has next pointer as null.
say a disk has 18 sectors numbered 1 to 18.
... 阅读全帖 |
|
n********y 发帖数: 66 | 43 file1 = sec1 -> sec7->sec9 -> sec11 -> null
file2 = sec10 -> sec12-> null
file1 should start from sec2 ?
For example
Sec1.block1: 2
block2: 10
block3: null
These data are lost. So we scan from Sec2, then follow pointer to 2,7,9,11
and record these positions. Write all the information as file1 to Sec1. Then
from next sector in 2-17 not used, do same thing.
when you're done, you get a your Sec1 back. |
|
j*****u 发帖数: 1133 | 44 1和k+1在第一步已经被分到不同的file里了,所以不会冲突
count完可以还原回原来的数字
比如size=100,array[1..100]在file1里表示1~100,file2里表示101~200, etc
我们不知道每个range究竟有多少数字,只能按照最坏情况下估计,这个时候hash反而不
如array efficient,而且当数字分布均匀的时候hash table占用的空间会比array还大
。
呢? |
|
b*******7 发帖数: 907 | 45 1. what's the output? why?
#include
#include
int main()
{
while(1)
{
fprintf(stdout,"hello-std-out");
fprintf(stderr,"hello-std-err");
sleep(1);
}
return 0;
}
2. what's the output?
#include
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", (int)a);
printf("%d\n", *(int *)&a);
return 0;
}
3. can it be built? if yes, what's the result?
file1.c:
int arr[80];
file2.c:
extern int *arr;
int main(... 阅读全帖 |
|
|
s****A 发帖数: 80 | 47 看书上说nonconst variables are extern by default, but to make const variable
accessible to other files we must explicitly specify that it is extern.
这么说的话如果我有两个文件:
//file1.cpp
int a=10;
extern int b=11;
void func(){
extern int c=12;
}
//file2.cpp
#include
int main(){
extern int a,b,c;
std::cout<
}
输出会是什么?谢谢! |
|
s****A 发帖数: 80 | 48 谢谢
如果在file2.cpp里main函数外再加一个
int a;
这个a会受file1.cpp里的a的值影响吗? |
|
S**I 发帖数: 15689 | 49 extern means "defined somewhere else", so your file1.cpp won't compile.
Talking about output from file2.cpp is meaningless.
variable |
|
u***8 发帖数: 1581 | 50 只有等receipt,这个需要1 2周。拿到后,打电话。貌似没有file2份opt的可能。 |
|