fs

HDFS的Shell操作

跟風遠走 提交于 2020-02-02 09:52:50
1、基本语法 bin/hadoop fs 具体命令 OR bin/hdfs dfs 具体命令 2、命令大全 [test@hadoop151 ~] $ hadoop fs Usage: hadoop fs [generic options] [ - appendToFile <localsrc> . . . <dst> ] [ - cat [ - ignoreCrc ] <src> . . . ] [ - checksum <src> . . . ] [ - chgrp [ - R ] GROUP PATH . . . ] [ - chmod [ - R ] <MODE [ , MODE ] . . . | OCTALMODE> PATH . . . ] [ - chown [ - R ] [OWNER] [ : [GROUP] ] PATH . . . ] [ - copyFromLocal [ - f ] [ - p ] [ - l ] <localsrc> . . . <dst> ] [ - copyToLocal [ - p ] [ - ignoreCrc ] [ - crc ] <src> . . . <localdst> ] [ - count [ - q ] [ - h ] <path> . . . ] [ - cp [ - f ] [ - p | - p [topax

【Hadoop学习之HDFS】_06HDFS的shell操作

与世无争的帅哥 提交于 2020-02-02 02:25:10
一、基本语法 bin/hadoop fs 具体命令 #或者 bin/hdfs dfs 具体命令 注意:其中 dfs 是 fs 的实现类 二、命令大全 [ hadoop@SZMaster01 hadoop-2.8.3 ] $ bin/hadoop fs Usage: hadoop fs [ generic options ] [ -appendToFile < localsrc > .. . < dst > ] [ -cat [ -ignoreCrc ] < src > .. . ] [ -checksum < src > .. . ] [ -chgrp [ -R ] GROUP PATH .. . ] [ -chmod [ -R ] < MODE [ ,MODE ] .. . | OCTALMODE > PATH .. . ] [ -chown [ -R ] [ OWNER ] [ : [ GROUP ] ] PATH .. . ] [ -copyFromLocal [ -f ] [ -p ] [ -l ] [ -d ] < localsrc > .. . < dst > ] [ -copyToLocal [ -f ] [ -p ] [ -ignoreCrc ] [ -crc ] < src > .. . < localdst > ] [ -count [ -q ] [ -h ]

Error: ENOENT: no such file or directory, unlink

故事扮演 提交于 2020-01-24 16:05:14
问题 As you can see, there is a file at the path. But fs says no such file or directory. I can't understand why? In another file, I can remove with the same code. My boat.js file: boat.findById(req.params.id,function(err, foundBoat) { if(err){ console.log(err); }else{ foundBoat.boatsFoto.forEach(function(path){ console.log(typeof(path)); fs.unlink("../public"+path,function(err){ if(err) throw err; console.log('File deleted!'); }); }); } }); And it is my error: Error: ENOENT: no such file or

Error: ENOENT: no such file or directory, unlink

为君一笑 提交于 2020-01-24 16:04:11
问题 As you can see, there is a file at the path. But fs says no such file or directory. I can't understand why? In another file, I can remove with the same code. My boat.js file: boat.findById(req.params.id,function(err, foundBoat) { if(err){ console.log(err); }else{ foundBoat.boatsFoto.forEach(function(path){ console.log(typeof(path)); fs.unlink("../public"+path,function(err){ if(err) throw err; console.log('File deleted!'); }); }); } }); And it is my error: Error: ENOENT: no such file or

How to read a symlink in Node.js

眉间皱痕 提交于 2020-01-24 05:44:05
问题 I want to read a symlink, and get the details of the link itself, not the contents of the linked file. How do I do that in Node, in a cross-platform way? I can detect symlinks easily using lstat , no problem. Once I know the path of the file, and that it is a symlink though, how can I read it? fs.readFile always reads the target file, or throws an error for reading a directory for links to directories. There is a fs.constants.O_SYMLINK constant, which in theory solves this on OSX, but it

Node fs.readdir freezing in folders with too many files

狂风中的少年 提交于 2020-01-23 17:28:47
问题 In Node.js I have to read files in a folder and for each file get file handler info, this is my simplest implementation using fs.readdir : FileServer.prototype.listLocal = function (params) { var self = this; var options = { limit: 100, desc: 1 }; // override defaults for (var attrname in params) { options[attrname] = params[attrname]; } // media path is the media folder var mediaDir = path.join(self._options.mediaDir, path.sep); return new Promise((resolve, reject) => { fs.readdir(mediaDir,

Add string on top file with NodeJS

烂漫一生 提交于 2020-01-15 10:13:46
问题 I would like add string on the top of my js file. Actuly, it's on the end : var file = './public/js/app.bundleES6.js', string = '// My string'; fs.appendFileSync(file, string); Do you have idea for add my string on the first line ? Thank you ! 回答1: I think there is no built-in way to insert at the beginning of the file in Node.js. But you can use readFileSync and writeFile methods of fs to resolve this issue It will append string at top of the file Try this Method#1 var fs = require('fs');

JSON Error when parsing “… has no method 'replace'”

痞子三分冷 提交于 2020-01-15 07:06:26
问题 Let me preface this with the admission that I am a complete programming and javascript noob and that fact is the source of my trouble. I'm trying to populate a large array of custom objects from a text file that I've saved to with json.stringify. When I grab the file contents and json.parse(them), I get the following error: var backSlashRemoved = text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@' ^ TypeError: Object (contents of file) has no method 'replace' The code that causes this

JSON Error when parsing “… has no method 'replace'”

南笙酒味 提交于 2020-01-15 07:06:20
问题 Let me preface this with the admission that I am a complete programming and javascript noob and that fact is the source of my trouble. I'm trying to populate a large array of custom objects from a text file that I've saved to with json.stringify. When I grab the file contents and json.parse(them), I get the following error: var backSlashRemoved = text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@' ^ TypeError: Object (contents of file) has no method 'replace' The code that causes this

Reading multiple files in parallel and writing the data in new files accordingly node.js

懵懂的女人 提交于 2020-01-06 12:48:53
问题 I'm trying to handle a asynchronous action that read multiple files from a folder at a same time and writes new ones in a different folder. The files that I read are by pair. One file is the data template and the other one is about the data. According to the template, we process the data from the related data file. All the information that I got from the both files are inserted into an object that I need to write in JSON into a new file . The code below works perfectly if there are only one