当前位置: 首页 > news >正文

linux cat命令增加-f显示文件名功能

在使用cat命令配合grep批量搜索文件内容时,我仅仅能知道是否搜索到,不知道是在哪个文件里找到的。比如cat ./src/*.c | grep full_write,在src目录下的所有.c文件里找full_write,能匹配到所有的full_write,但是不知道它们分别在哪些文件里。于是我给cat命令增加了一个-f功能,这样能在每一行前面加上文件名,并且加一个冒号':'。这样就能直观的知道它们分别是在哪个文件里找到的,命令为cat ./src/*.c -f | grep full_write。找到之后再配合-n,就能显示出它是在哪个文件的哪一行,cat ./src/x.c -n | grep full_write。

对比效果

拉取项目

git clone https://git.savannah.gnu.org/git/coreutils.git

做出改动的源文件

./src/cat.c

对比改动

修改后的cat.c文件

/* cat -- concatenate files and print on the standard output.Copyright (C) 1988-2023 Free Software Foundation, Inc.This program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program.  If not, see <https://www.gnu.org/licenses/>.  *//* Differences from the Unix cat:* Always unbuffered, -u is ignored.* Usually much faster than other versions of cat, the differenceis especially apparent when using the -v option.By tege@sics.se, Torbjörn Granlund, advised by rms, Richard Stallman.  */#include <config.h>#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>#if HAVE_STROPTS_H
# include <stropts.h>
#endif
#include <sys/ioctl.h>#include "system.h"
#include "alignalloc.h"
#include "ioblksize.h"
#include "fadvise.h"
#include "full-write.h"
#include "safe-read.h"
#include "xbinary-io.h"/* The official name of this program (e.g., no 'g' prefix).  */
#define PROGRAM_NAME "cat"#define AUTHORS \proper_name_lite ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \proper_name ("Richard M. Stallman")/* Name of input file.  May be "-".  */
static char const *infile;/* Descriptor on which input file is open.  */
static int input_desc;/* Buffer for line numbers.An 11 digit counter may overflow within an hour on a P2/466,an 18 digit counter needs about 1000y */
#define LINE_COUNTER_BUF_LEN 20
static char line_buf[LINE_COUNTER_BUF_LEN] ={' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0','\t', '\0'};/* Position in 'line_buf' where printing starts.  This will not changeunless the number of lines is larger than 999999.  */
static char *line_num_print = line_buf + LINE_COUNTER_BUF_LEN - 8;/* Position of the first digit in 'line_buf'.  */
static char *line_num_start = line_buf + LINE_COUNTER_BUF_LEN - 3;/* Position of the last digit in 'line_buf'.  */
static char *line_num_end = line_buf + LINE_COUNTER_BUF_LEN - 3;/* Preserves the 'cat' function's local 'newlines' between invocations.  */
static int newlines2 = 0;/* Whether there is a pending CR to process.  */
static bool pending_cr = false;void
usage (int status)
{if (status != EXIT_SUCCESS)emit_try_help ();else{printf (_("\
Usage: %s [OPTION]... [FILE]...\n\
"),program_name);fputs (_("\
Concatenate FILE(s) to standard output.\n\
"), stdout);emit_stdin_note ();fputs (_("\
\n\-A, --show-all           equivalent to -vET\n\-b, --number-nonblank    number nonempty output lines, overrides -n\n\-e                       equivalent to -vE\n\-E, --show-ends          display $ at end of each line\n\-n, --number             number all output lines\n\-s, --squeeze-blank      suppress repeated empty output lines\n\
"), stdout);fputs (_("\-t                       equivalent to -vT\n\-T, --show-tabs          display TAB characters as ^I\n\-u                       (ignored)\n\-f, --show-filename      display filename at begin of each line\n\-v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB\n\
"), stdout);fputs (HELP_OPTION_DESCRIPTION, stdout);fputs (VERSION_OPTION_DESCRIPTION, stdout);printf (_("\
\n\
Examples:\n\%s f - g  Output f's contents, then standard input, then g's contents.\n\%s        Copy standard input to standard output.\n\
"),program_name, program_name);emit_ancillary_info (PROGRAM_NAME);}exit (status);
}/* Compute the next line number.  */static void
next_line_num (void)
{char *endp = line_num_end;do{if ((*endp)++ < '9')return;*endp-- = '0';}while (endp >= line_num_start);if (line_num_start > line_buf)*--line_num_start = '1';else*line_buf = '>';if (line_num_start < line_num_print)line_num_print--;
}/* Plain cat.  Copy the file behind 'input_desc' to STDOUT_FILENO.BUF (of size BUFSIZE) is the I/O buffer, used by reads and writes.Return true if successful.  */static bool
simple_cat (char *buf, idx_t bufsize)
{/* Loop until the end of the file.  */while (true){/* Read a block of input.  */size_t n_read = safe_read (input_desc, buf, bufsize);if (n_read == SAFE_READ_ERROR){error (0, errno, "%s", quotef (infile));return false;}/* End of this file?  */if (n_read == 0)return true;/* Write this block out.  */if (full_write (STDOUT_FILENO, buf, n_read) != n_read)write_error ();}
}/* Write any pending output to STDOUT_FILENO.Pending is defined to be the *BPOUT - OUTBUF bytes starting at OUTBUF.Then set *BPOUT to OUTPUT if it's not already that value.  */static inline void
write_pending (char *outbuf, char **bpout)
{idx_t n_write = *bpout - outbuf;if (0 < n_write){if (full_write (STDOUT_FILENO, outbuf, n_write) != n_write)write_error ();*bpout = outbuf;}
}/* Copy the file behind 'input_desc' to STDOUT_FILENO.Use INBUF and read INSIZE with each call,and OUTBUF and write OUTSIZE with each call.(The buffers are a bit larger than the I/O sizes.)The remaining boolean args say what 'cat' options to use.Return true if successful.Called if any option more than -u was specified.A newline character is always put at the end of the buffer, to makean explicit test for buffer end unnecessary.  */static bool
cat (char *inbuf, idx_t insize, char *outbuf, idx_t outsize,bool show_nonprinting, bool show_tabs, bool number, bool number_nonblank,bool show_ends, bool squeeze_blank, bool show_filename)
{/* Last character read from the input buffer.  */unsigned char ch;/* Determines how many consecutive newlines there have been in theinput.  0 newlines makes NEWLINES -1, 1 newline makes NEWLINES 1,etc.  Initially 0 to indicate that we are at the beginning of anew line.  The "state" of the procedure is determined byNEWLINES.  */int newlines = newlines2;#ifdef FIONREAD/* If nonzero, use the FIONREAD ioctl, as an optimization.(On Ultrix, it is not supported on NFS file systems.)  */bool use_fionread = true;
#endif/* The inbuf pointers are initialized so that BPIN > EOB, and thereby inputis read immediately.  *//* Pointer to the first non-valid byte in the input buffer, i.e., thecurrent end of the buffer.  */char *eob = inbuf;/* Pointer to the next character in the input buffer.  */char *bpin = eob + 1;/* Pointer to the position where the next character shall be written.  */char *bpout = outbuf;while (true){do{/* Write if there are at least OUTSIZE bytes in OUTBUF.  */if (outbuf + outsize <= bpout){char *wp = outbuf;idx_t remaining_bytes;do{if (full_write (STDOUT_FILENO, wp, outsize) != outsize)write_error ();wp += outsize;remaining_bytes = bpout - wp;}while (outsize <= remaining_bytes);/* Move the remaining bytes to the beginning of thebuffer.  */memmove (outbuf, wp, remaining_bytes);bpout = outbuf + remaining_bytes;}/* Is INBUF empty?  */if (bpin > eob){bool input_pending = false;
#ifdef FIONREADint n_to_read = 0;/* Is there any input to read immediately?If not, we are about to wait,so write all buffered output before waiting.  */if (use_fionread&& ioctl (input_desc, FIONREAD, &n_to_read) < 0){/* Ultrix returns EOPNOTSUPP on NFS;HP-UX returns ENOTTY on pipes.SunOS returns EINVAL andMore/BSD returns ENODEV on special fileslike /dev/null.Irix-5 returns ENOSYS on pipes.  */if (errno == EOPNOTSUPP || errno == ENOTTY|| errno == EINVAL || errno == ENODEV|| errno == ENOSYS)use_fionread = false;else{error (0, errno, _("cannot do ioctl on %s"),quoteaf (infile));newlines2 = newlines;return false;}}if (n_to_read != 0)input_pending = true;
#endifif (!input_pending)write_pending (outbuf, &bpout);/* Read more input into INBUF.  */size_t n_read = safe_read (input_desc, inbuf, insize);if (n_read == SAFE_READ_ERROR){error (0, errno, "%s", quotef (infile));write_pending (outbuf, &bpout);newlines2 = newlines;return false;}if (n_read == 0){write_pending (outbuf, &bpout);newlines2 = newlines;return true;}/* Update the pointers and insert a sentinel at the bufferend.  */bpin = inbuf;eob = bpin + n_read;*eob = '\n';}else{/* It was a real (not a sentinel) newline.  *//* Was the last line empty?(i.e., have two or more consecutive newlines been read?)  */if (++newlines > 0){if (newlines >= 2){/* Limit this to 2 here.  Otherwise, with lots ofconsecutive newlines, the counter could wraparound at INT_MAX.  */newlines = 2;/* Are multiple adjacent empty lines to be substitutedby single ditto (-s), and this was the second emptyline?  */if (squeeze_blank){ch = *bpin++;continue;}}/* Are line numbers to be written at empty lines (-n)?  */if (number && !number_nonblank){next_line_num ();bpout = stpcpy (bpout, line_num_print);}}/* Output a currency symbol if requested (-e).  */if (show_ends){if (pending_cr){*bpout++ = '^';*bpout++ = 'M';pending_cr = false;}*bpout++ = '$';}/* Output the newline.  */*bpout++ = '\n';}ch = *bpin++;}while (ch == '\n');/* Here CH cannot contain a newline character.  */if (pending_cr){*bpout++ = '\r';pending_cr = false;}/* Are we at the beginning of a line, and filename are requested? */if (newlines >= 0 && show_filename){bpout = stpcpy (bpout, infile);*bpout++ = ':';}/* Are we at the beginning of a line, and line numbers are requested?  */if (newlines >= 0 && number){next_line_num ();bpout = stpcpy (bpout, line_num_print);}/* The loops below continue until a newline character is found,which means that the buffer is empty or that a proper newlinehas been found.  *//* If quoting, i.e., at least one of -v, -e, or -t specified,scan for chars that need conversion.  */if (show_nonprinting){while (true){if (ch >= 32){if (ch < 127)*bpout++ = ch;else if (ch == 127){*bpout++ = '^';*bpout++ = '?';}else{*bpout++ = 'M';*bpout++ = '-';if (ch >= 128 + 32){if (ch < 128 + 127)*bpout++ = ch - 128;else{*bpout++ = '^';*bpout++ = '?';}}else{*bpout++ = '^';*bpout++ = ch - 128 + 64;}}}else if (ch == '\t' && !show_tabs)*bpout++ = '\t';else if (ch == '\n'){newlines = -1;break;}else{*bpout++ = '^';*bpout++ = ch + 64;}ch = *bpin++;}}else{/* Not quoting, neither of -v, -e, or -t specified.  */while (true){if (ch == '\t' && show_tabs){*bpout++ = '^';*bpout++ = ch + 64;}else if (ch != '\n'){if (ch == '\r' && *bpin == '\n' && show_ends){if (bpin == eob)pending_cr = true;else{*bpout++ = '^';*bpout++ = 'M';}}else*bpout++ = ch;}else{newlines = -1;break;}ch = *bpin++;}}}
}/* Copy data from input to output using copy_file_range if possible.Return 1 if successful, 0 if ordinary read+write should be tried,-1 if a serious problem has been diagnosed.  */static int
copy_cat (void)
{/* Copy at most COPY_MAX bytes at a time; this is min(SSIZE_MAX, SIZE_MAX) truncated to a value that issurely aligned well.  */ssize_t copy_max = MIN (SSIZE_MAX, SIZE_MAX) >> 30 << 30;/* copy_file_range does not support some cases, and itincorrectly returns 0 when reading from the proc filesystem on the Linux kernel through at least 5.6.19 (2020),so fall back on read+write if the copy_file_range isunsupported or the input file seems empty.  */for (bool some_copied = false; ; some_copied = true)switch (copy_file_range (input_desc, nullptr, STDOUT_FILENO, nullptr,copy_max, 0)){case 0:return some_copied;case -1:if (errno == ENOSYS || is_ENOTSUP (errno) || errno == EINVAL|| errno == EBADF || errno == EXDEV || errno == ETXTBSY|| errno == EPERM)return 0;error (0, errno, "%s", quotef (infile));return -1;}
}int
main (int argc, char **argv)
{/* Nonzero if we have ever read standard input.  */bool have_read_stdin = false;struct stat stat_buf;/* Variables that are set according to the specified options.  */bool number = false;bool number_nonblank = false;bool squeeze_blank = false;bool show_ends = false;bool show_nonprinting = false;bool show_tabs = false;bool show_filename = false;int file_open_mode = O_RDONLY;static struct option const long_options[] ={{"number-nonblank", no_argument, nullptr, 'b'},{"number", no_argument, nullptr, 'n'},{"squeeze-blank", no_argument, nullptr, 's'},{"show-nonprinting", no_argument, nullptr, 'v'},{"show-ends", no_argument, nullptr, 'E'},{"show-tabs", no_argument, nullptr, 'T'},{"show-all", no_argument, nullptr, 'A'},{"show-filename", no_argument, nullptr, 'f'},{GETOPT_HELP_OPTION_DECL},{GETOPT_VERSION_OPTION_DECL},{nullptr, 0, nullptr, 0}};initialize_main (&argc, &argv);set_program_name (argv[0]);setlocale (LC_ALL, "");bindtextdomain (PACKAGE, LOCALEDIR);textdomain (PACKAGE);/* Arrange to close stdout if we exit via thecase_GETOPT_HELP_CHAR or case_GETOPT_VERSION_CHAR code.Normally STDOUT_FILENO is used rather than stdout, soclose_stdout does nothing.  */atexit (close_stdout);/* Parse command line options.  */int c;while ((c = getopt_long (argc, argv, "befnstuvAET", long_options, nullptr))!= -1){switch (c){case 'b':number = true;number_nonblank = true;break;case 'e':show_ends = true;show_nonprinting = true;break;case 'n':number = true;break;case 's':squeeze_blank = true;break;case 't':show_tabs = true;show_nonprinting = true;break;case 'u':/* We provide the -u feature unconditionally.  */break;case 'v':show_nonprinting = true;break;case 'A':show_nonprinting = true;show_ends = true;show_tabs = true;break;case 'E':show_ends = true;break;case 'T':show_tabs = true;break;case 'f':show_filename = true;break;case_GETOPT_HELP_CHAR;case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);default:usage (EXIT_FAILURE);}}/* Get device, i-node number, and optimal blocksize of output.  */if (fstat (STDOUT_FILENO, &stat_buf) < 0)error (EXIT_FAILURE, errno, _("standard output"));/* Optimal size of i/o operations of output.  */idx_t outsize = io_blksize (&stat_buf);/* Device and I-node number of the output.  */dev_t out_dev = stat_buf.st_dev;ino_t out_ino = stat_buf.st_ino;/* True if the output is a regular file.  */bool out_isreg = S_ISREG (stat_buf.st_mode) != 0;if (! (number || show_ends || squeeze_blank)){file_open_mode |= O_BINARY;xset_binary_mode (STDOUT_FILENO, O_BINARY);}/* Main loop.  */infile = "-";int argind = optind;bool ok = true;idx_t page_size = getpagesize ();do{if (argind < argc)infile = argv[argind];bool reading_stdin = STREQ (infile, "-");if (reading_stdin){have_read_stdin = true;input_desc = STDIN_FILENO;if (file_open_mode & O_BINARY)xset_binary_mode (STDIN_FILENO, O_BINARY);}else{input_desc = open (infile, file_open_mode);if (input_desc < 0){error (0, errno, "%s", quotef (infile));ok = false;continue;}}if (fstat (input_desc, &stat_buf) < 0){error (0, errno, "%s", quotef (infile));ok = false;goto contin;}/* Optimal size of i/o operations of input.  */idx_t insize = io_blksize (&stat_buf);fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL);/* Don't copy a nonempty regular file to itself, as that wouldmerely exhaust the output device.  It's better to catch thiserror earlier rather than later.  */if (out_isreg&& stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino&& lseek (input_desc, 0, SEEK_CUR) < stat_buf.st_size){error (0, 0, _("%s: input file is output file"), quotef (infile));ok = false;goto contin;}/* Pointer to the input buffer.  */char *inbuf;/* Select which version of 'cat' to use.  If any format-orientedoptions were given use 'cat'; if not, use 'copy_cat' if itworks, 'simple_cat' otherwise.  */if (! (number || show_ends || show_nonprinting|| show_tabs || squeeze_blank || show_filename)){int copy_cat_status =out_isreg && S_ISREG (stat_buf.st_mode) ? copy_cat () : 0;if (copy_cat_status != 0){inbuf = nullptr;ok &= 0 < copy_cat_status;}else{insize = MAX (insize, outsize);inbuf = xalignalloc (page_size, insize);ok &= simple_cat (inbuf, insize);}}else{/* Allocate, with an extra byte for a newline sentinel.  */inbuf = xalignalloc (page_size, insize + 1);/* Why are(OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN)bytes allocated for the output buffer?A test whether output needs to be written is done when the inputbuffer empties or when a newline appears in the input.  Afteroutput is written, at most (OUTSIZE - 1) bytes will remain in thebuffer.  Now INSIZE bytes of input is read.  Each input charactermay grow by a factor of 4 (by the prepending of M-^).  If allcharacters do, and no newlines appear in this block of input, wewill have at most (OUTSIZE - 1 + INSIZE * 4) bytes in the buffer.If the last character in the preceding block of input was anewline, a line number may be written (according to the givenoptions) as the first thing in the output buffer. (Done after thenew input is read, but before processing of the input begins.)A line number requires seldom more than LINE_COUNTER_BUF_LENpositions.Align the output buffer to a page size boundary, for efficiencyon some paging implementations.  */idx_t bufsize;if (ckd_mul (&bufsize, insize, 4)|| ckd_add (&bufsize, bufsize, outsize)|| ckd_add (&bufsize, bufsize, LINE_COUNTER_BUF_LEN - 1))xalloc_die ();char *outbuf = xalignalloc (page_size, bufsize);ok &= cat (inbuf, insize, outbuf, outsize, show_nonprinting,show_tabs, number, number_nonblank, show_ends,squeeze_blank, show_filename);alignfree (outbuf);}alignfree (inbuf);contin:if (!reading_stdin && close (input_desc) < 0){error (0, errno, "%s", quotef (infile));ok = false;}}while (++argind < argc);if (pending_cr){if (full_write (STDOUT_FILENO, "\r", 1) != 1)write_error ();}if (have_read_stdin && close (STDIN_FILENO) < 0)error (EXIT_FAILURE, errno, _("closing standard input"));return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}

相关文章:

linux cat命令增加-f显示文件名功能

在使用cat命令配合grep批量搜索文件内容时&#xff0c;我仅仅能知道是否搜索到&#xff0c;不知道是在哪个文件里找到的。比如cat ./src/*.c | grep full_write,在src目录下的所有.c文件里找full_write,能匹配到所有的full_write&#xff0c;但是不知道它们分别在哪些文件里。于…...

linux更改登录shell

从bash修改成python 在/etc/passwd下可以更改用户登录bash 例 root:x:0:0:root:/root:/bin/bash //更改bin/bash为/bin/python&#xff0c;就可以用root登录python页面了从python修改成bash 方法一 重启页面按e进入内核编辑模式linux16这行后添加&#xff1a;init/bin/…...

【JS】报错:Uncaught TypeError: Cannot read properties of null (reading ‘classList‘)

错误展示 今天写js代码的时候遇到报错&#xff1a; 源代码&#xff1a; <ul class"slider-indicator"><li class"active"></li><li></li><li></li><li></li><li></li><li><…...

kali2.0安装VMware Tools 和自定义改变分辨率

kali2.0安装VMware Tools 和自定义改变分辨率 VMware Tools 简介&#xff1a;VMware Tools安装&#xff1a;自定义改变分辨率&#xff1a;xrandr命令修改分辨率&#xff1a; 前言&#xff1a; 因为kali2.0比较老 所以需要手动安装 WMware Tools 进行复制粘贴操作&#xff01; …...

redis中根据通配符删除key

redis中根据通配符删除key 我们是不是在redis中keys user:*可以获取所有key&#xff0c;但是 del user:*却不行这里我提供的命令主要是SCANSCAN 0 MATCH user:* COUNT 100使用lua保证原子性 SCAN参数描述 在示例中&#xff0c;COUNT 被设置为 100。这是一个防止一次性获取大…...

【HDFS联邦(2)】HDFS Router-based Federation官网解读:HDFSRouterFederation的架构、各组件基本原理

文章目录 一. 介绍二、HDFS Router-based Federation 架构1. 示例说明2. Router2.1. Federated interface2.2. Router heartbeat2.3. NameNode heartbeat2.4. Availability and fault toleranceInterfaces 3. Quota management4. State Store 三、部署 ing 本文主要参考官网&am…...

【头歌实训】Spark 完全分布式的安装和部署

文章目录 第1关&#xff1a; Standalone 分布式集群搭建任务描述相关知识课程视频Spark分布式安装模式示例集群信息配置免密登录准备Spark安装包配置环境变量修改 spark-env.sh 配置文件修改 slaves 文件分发安装包启动spark验证安装 编程要求测试说明答案代码报错问题基本过程…...

Leetcode—86.分隔链表【中等】

2023每日刷题&#xff08;六十九&#xff09; Leetcode—86.分隔链表 实现代码 /*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/ struct ListNode* partition(struct ListNode* head, int x) {struct ListNode…...

淘宝/天猫商品API:实时数据获取与安全隐私保护的指南

一、引言 随着电子商务的快速发展&#xff0c;淘宝/天猫等电商平台已成为商家和消费者的重要交易场所。对于电商企业而言&#xff0c;实时掌握店铺商品的销售情况、库存状态等信息至关重要。然而&#xff0c;手动管理和更新商品信息既费时又费力。因此&#xff0c;淘宝/天猫提…...

使用 SSH 方式实现 Git 远程连接GitHub

git是目前世界上最先进的分布式版本控制系统&#xff0c;相比于SVN&#xff0c;分布式版本系统的最大好处之一是在本地工作完全不需要考虑远程库的存在&#xff0c;也就是有没有联网都可以正常工作&#xff01;当有网络的时候&#xff0c;再把本地提交推送一下就完成了同步&…...

Centos7部署Keepalived+lvs服务

IP规划&#xff1a; 服务器IP地址主服务器20.0.0.22/24从服务器20.0.0.24/24Web-120.0.0.26/24Web-220.0.0.27/24 一、主服务器安装部署keepalivedlvs服务 1、调整/proc响应参数 关闭Linux内核的重定向参数&#xff0c;因为LVS负载服务器和两个页面服务器需要共用一个VIP地…...

12/31

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 摘要Abstract文献阅读&#xff1a;用于密集预测的多路径视觉Transformer1、研究背景2、方法提出3、相关方法3.1、Vision Transformers for dense predictions3.2、C…...

python使用openpyxl为excel模版填充数据,生成多个Sheet页面

目标&#xff1a;希望根据一个给定的excel模版&#xff0c;生成多个Sheet页面&#xff0c;比如模版&#xff1a; 示例程序 import openpyxlexcel_workbook openpyxl.load_workbook("模版.xlsx") for _i in range(3): # 比如填充3个页面# 复制模版sheet页&#x…...

基于ssm的4S店预约保养系统开发+vue论文

目 录 目 录 I 摘 要 III ABSTRACT IV 1 绪论 1 1.1 课题背景 1 1.2 研究现状 1 1.3 研究内容 2 2 系统开发环境 3 2.1 vue技术 3 2.2 JAVA技术 3 2.3 MYSQL数据库 3 2.4 B/S结构 4 2.5 SSM框架技术 4 3 系统分析 5 3.1 可行性分析 5 3.1.1 技术可行性 5 3.1.2 操作可行性 5 3…...

【Git】Git的基本操作

前言 Git是当前最主流的版本管理器&#xff0c;它可以控制电脑上的所有格式的文件。 它对于开发人员&#xff0c;可以管理项目中的源代码文档。&#xff08;可以记录不同提交的修改细节&#xff0c;并且任意跳转版本&#xff09; 本篇博客基于最近对Git的学习&#xff0c;简单介…...

【超图】SuperMap iClient3D for WebGL/WebGPU —— 数据集合并缓存如何控制对象样式

作者&#xff1a;taco 最近在支持的过程中&#xff0c;遇到了一个新问题&#xff01;之前研究功能的时候竟然没有想到。通常我们控制单个对象的显隐、颜色、偏移的参数都是根据对象所在的图层以及对象单独的id来算的。那么问题来了&#xff0c;合并后的图层。他怎么控制单个对象…...

intellij IDEA开发工具的使用(打开/关闭工程;删除类文件;修改类/包/模块/项目名称;导入/删除模块)

1&#xff0c;打开工程 打开IDEA&#xff0c;会看到如下界面 1栏目里是自己曾经打开过的project&#xff08;工程&#xff09;&#xff0c;直接点击就好。如果需要打开其他工程&#xff0c;则点击open&#xff0c;会出下以下界面。 选择需要加载的project&#xff08;工程&…...

抖音详情API:开发环境搭建与工具选择

随着短视频的流行&#xff0c;抖音已经成为了一个备受欢迎的社交媒体平台。对于开发人员而言&#xff0c;利用抖音详情API开发定制化的抖音应用具有巨大的潜力。本文将为你详细介绍开发抖音应用的开发环境搭建与工具选择&#xff0c;帮助你顺利地开始开发工作。 一、开发环境搭…...

IntelliJ IDEA [插件 MybatisX] mapper和xml间跳转

文章目录 1. 安装插件2. 如何使用3. 主要功能总结 MybatisX 是一款为 IntelliJ IDEA 提供支持的 MyBatis 开发插件 它通过提供丰富的功能集&#xff0c;大大简化了 MyBatis XML 文件的编写、映射关系的可视化查看以及 SQL 语句的调试等操作。本文将介绍如何安装、配置和使用 In…...

Havenask 分布式索引构建服务 --Build Service

Havenask 是阿里巴巴智能引擎事业部自研的开源高性能搜索引擎&#xff0c;深度支持了包括淘宝、天猫、菜鸟、高德、饿了么在内几乎整个阿里的搜索业务。本文针对性介绍了 Havenask 分布式索引构建服务——Build Service&#xff0c;主打稳定、快速、易管理&#xff0c;是在线系…...

vscode软件安装步骤

目录 一、下载软件安装包 二、运行安装包后 一、下载软件安装包 打开vscode官方网址&#xff0c;找到下载界面 链接如下&#xff1a;Download Visual Studio Code - Mac, Linux, Windows 我是windows电脑&#xff0c;各位小伙伴自己选择合适的版本&#xff0c;点击下载按钮…...

C语言中灵活多变的动态内存,malloc函数 free函数 calloc函数 realloc函数

文章目录 &#x1f680;前言&#x1f680;管理动态内存的函数✈️malloc函数✈️free函数✈️calloc函数✈️realloc函数 &#x1f680;在使用动态内存函数时的常见错误✈️对NULL指针的解引用✈️ 对动态开辟空间的越界访问✈️对非动态开辟内存使用free释放✈️使用free释放一…...

小细节处理

重载运算符&#xff1a;重载<运算符。 bool operator<(const Edge&s)const{return w<s.w;}...

【42页动态规划学习笔记分享】动态规划核心原理详解及27道LeetCode相关经典题目汇总

《博主简介》 小伙伴们好&#xff0c;我是阿旭。专注于人工智能AI、python、计算机视觉相关分享研究。 ✌更多学习资源&#xff0c;可关注公-仲-hao:【阿旭算法与机器学习】&#xff0c;共同学习交流~ &#x1f44d;感谢小伙伴们点赞、关注&#xff01; 《------往期经典推荐--…...

Python正则的匹配与替换

import re 查找时的注意事项&#xff0c;要查找的内容左右两边打出来&#xff0c;用真正的字符&#xff0c;不要用.*?&#xff0c;离查找内容远一点&#xff0c;再用.*? a /aksj<a>哈哈哈<a><p>拉阿鲁<p>\.askjp b re.findall(<a>(.*?)<…...

解决ELement-UI懒加载三级联动数据不回显(天坑)

最老是遇到这类问题头有点大,最后也是解决了,为铁铁们总结了一下几点 一.查看数据类型是否一致 未选择下 选择下 二.处理数据时使用this.$set方法来动态地设置实例中的属性&#xff0c;以确保其响应式 三.绑定v-if 确保每次重新加载 四.绑定key 五.完整代码...

【数据结构和算法】找出两数组的不同

其他系列文章导航 Java基础合集数据结构与算法合集 设计模式合集 多线程合集 分布式合集 ES合集 文章目录 其他系列文章导航 文章目录 前言 一、题目描述 二、题解 2.1 哈希类算法题注意事项 2.2 方法一&#xff1a;哈希法 三、代码 3.1 方法一&#xff1a;哈希法 四…...

基于Python的B站排行榜大数据分析与可视化系统

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长 QQ 名片 :) 1. 项目简介 本文介绍了一项基于Python的B站排行榜大数据分析与可视化系统的研究。通过网络爬虫技术&#xff0c;系统能够自动分析B站网址&#xff0c;提取大量相关文本信息并存储在系统中。通过对这些信息进行…...

MySQL一些常用命令

1、登录本地MySQL #一种是 mysql -u root -p; #(输入密码后回车)#另一种是 mysql -uroot -p123456; #(在-p后面直接带上密码)2、启动MySQL服务 net start mysql; 3、关闭MySQL服务&#xff1a; net stop mysql; 4、创建数据库 create database 数据库名; 5、创建数据…...

WPF 新手指引弹窗

新手指引弹窗介绍 我们在第一次使用某个软件时&#xff0c;通常会有一个“新手指引”教学引导。WPF实现“新手指引”非常方便&#xff0c;且非常有趣。接下来我们就开始制作一个简单的”新手指引”(代码简单易懂&#xff0c;便于移植)&#xff0c;引用到我们的项目中又可添加一…...

py注册登录界面

代码分析 引入tkinter库&#xff0c;并从中导入messagebox模块。 read_users()函数用于读取存储用户信息的文本文件"users.txt"。它打开文件并逐行读取&#xff0c;将每行的用户名和密码以空格分隔后存储在一个列表中&#xff0c;最后返回该列表。 login(username,…...

基于电商场景的高并发RocketMQ实战-Consumer端队列负载均衡分配机制、并发消费以及消费进度提交

&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308; 【11来了】文章导读地址&#xff1a;点击查看文章导读&#xff01; &#x1f341;&#x1f341;&#x1f341;&#x1f341;&#x1f341;&#x1f341;&#x1f3…...

【Java开发岗面试】八股文—数据库MySQLRedis

声明&#xff1a; 背景&#xff1a;本人为24届双非硕校招生&#xff0c;已经完整经历了一次秋招&#xff0c;拿到了三个offer。本专题旨在分享自己的一些Java开发岗面试经验&#xff08;主要是校招&#xff09;&#xff0c;包括我自己总结的八股文、算法、项目介绍、HR面和面试…...

IntelliJ IDEA [设置] 隐藏 .idea 等 .XXX 文件夹

文章目录 1. 问题描述2. 解决办法3. 最后效果4. 特殊处理&#xff08;正常不需要此步骤&#xff09;总结 我们使用 IntelliJ IDEA 导入项目的时候&#xff0c;经常会看到一些 .XXX 的文件夹&#xff08;例如&#xff1a;.idea&#xff0c;.mvn&#xff0c;.gradle 等&#xff0…...

每日一题——LeetCode961

方法一 排序法&#xff1a; 2*n长度的数组里面有一个元素重复了n次&#xff0c;那么将数组排序&#xff0c;求出排序后数组的中间值&#xff08;因为长度是偶数&#xff0c;没有刚好的中间值&#xff0c;默认求的中间值是偏左边的那个&#xff09;那么共有三种情况&#xff1a;…...

基于Unity Editor开发一个技能编辑器可能涉及到的内容

基于Unity Editor开发一个技能编辑器&#xff0c;涉及到的方面较多&#xff0c;涵盖了Unity自身的GUI框架、序列化系统、自定义编辑器、脚本调用与数据存储等。下面是几个关键点和你可能会用到的类以及API&#xff1a; 自定义Inspector&#xff1a; 使用Editor类来重写组件的I…...

Ubuntu 22.04 安装ftp实现与windows文件互传

Ubuntu 22.04 安装ftp实现与windows文件互传 1、配置安装 安装&#xff1a; sudo apt install vsftpd -y使能开机自启&#xff1a; sudo systemctl enable vsftpd 启动&#xff1a; sudo systemctl start vsftpd创建ftp工作目录&#xff1a; sudo mkdir -p /home/ftp/uftp…...

EasyPoi使用案例

EasyPoi使用案例 easypoi旨在简化Excel和Word的操作。基于注解的导入导出&#xff0c;修改注解就可以修改Excel&#xff1b;支持常用的样式自定义&#xff1b;基于map可以灵活定义表头字段&#xff1b;支持一对多的导入导出&#xff1b;支持模板的导出&#xff1b;支持HTML/Exc…...

分布式系统架构设计之分布式数据存储的分类和组合策略

在现下科技发展迅猛的背景下&#xff0c;分布式系统已经成为许多大规模应用和服务的基础架构。分布式架构的设计不仅仅是一项技术挑战&#xff0c;更是对数据存储、管理和处理能力的严峻考验。随着云原生、大数据、人工智能等技术的崛起&#xff0c;分布式系统对于数据的高效存…...

javaEE -18(11000字 JavaScript入门 - 3)

一&#xff1a;事件 &#xff08;高级&#xff09; 1.1 注册事件&#xff08;绑定事件&#xff09; 给元素添加事件&#xff0c;称为注册事件或者绑定事件&#xff0c;注册事件有两种方式&#xff1a;传统方式和方法监听注册方式 传统注册方式 &#xff1a; 利用 on 开头的…...

LangChain.js 实战系列:入门介绍

&#x1f4dd; LangChain.js 是一个快速开发大模型应用的框架&#xff0c;它提供了一系列强大的功能和工具&#xff0c;使得开发者能够更加高效地构建复杂的应用程序。LangChain.js 实战系列文章将介绍在实际项目中使用 LangChain.js 时的一些方法和技巧。 LangChain.js 是一个…...

pyCharm 打印控制台中文乱码解决办法

解决方法 在 "File" -> "Settings" 中的控制台设置&#xff1a; 在 "File" -> "Settings" 中&#xff0c;你可以找到 "Editor" -> "General" -> "Console"。在这里&#xff0c;你可能会找到…...

计算机基础--Linux详解

一概述 Linux是一种自由和开放源码的类UNIX操作系统。它是由林纳斯托瓦兹于1991年首次发布的&#xff0c;并从那时起在全球范围内得到了广泛的应用和开发。Linux具有强大的可定制性&#xff0c;可以运行在各种硬件平台上&#xff0c;包括x86、ARM、MIPS等。它不仅广泛应用于服…...

基于OpenAI的Whisper构建的高效语音识别模型:faster-whisper

1 faster-whisper介绍 faster-whisper是基于OpenAI的Whisper模型的高效实现&#xff0c;它利用CTranslate2&#xff0c;一个专为Transformer模型设计的快速推理引擎。这种实现不仅提高了语音识别的速度&#xff0c;还优化了内存使用效率。faster-whisper的核心优势在于其能够在…...

cfa一级考生复习经验分享系列(十六)

写在前面&#xff1a;并不鼓励大家在考前一个月才开始复习&#xff0c;不过&#xff0c;既然已经逼到了绝境&#xff0c;灰心丧气也没有用&#xff0c;不如放手一搏&#xff01; 首先说一下我的背景&#xff0c;工作金融机构的it&#xff0c;和cfa基本没关系&#xff0c;本硕计…...

数模学习day05-插值算法

插值算法有什么作用呢&#xff1f; 答&#xff1a;数模比赛中&#xff0c;常常需要根据已知的函数点进行数据、模型的处理和分析&#xff0c;而有时候现有的数据是极少的&#xff0c;不足以支撑分析的进行&#xff0c;这时就需要使用一些数学的方法&#xff0c;“模拟产生”一些…...

hive中struct相关函数总结

目录 hive官方函数解释示例实战 hive官方函数解释 hive官网函数大全地址&#xff1a;添加链接描述 Return TypeNameDescriptionstructstruct(val1, val2, val3, …)Creates a struct with the given field values. Struct field names will be col1, col2, …structnamed_str…...

macos下转换.dmg文件为 .iso .cdr文件的简单方法

为了让镜像文件在mac 和windows平台通用, 所以需要将.dmg格式的镜像文件转换为.iso文件, 转换方法也非常简单, 一行命令即可 hdiutil convert /path/to/example.dmg -format UDTO -o /path/to/example.iso 转换完成后的文件名称默认是 example.iso.cdr 这里直接将.cdr后缀删…...

ALSA学习(5)——设备中的alsa

参考博客&#xff1a; https://blog.csdn.net/DroidPhone/article/details/7165482 &#xff08;一下内容基本是原博主的博客转载&#xff09; 文章目录 一、ASOC的由来二、硬件架构三、软件架构四、数据结构五、内核对ASoC的改进 一、ASOC的由来 ASoC–ALSA System on Chip …...

uniapp中组件库的丰富NumberBox 步进器的用法

目录 基本使用 #步长设置 #限制输入范围 #限制只能输入整数 #禁用 #固定小数位数 #异步变更 #自定义颜色和大小 #自定义 slot API #Props #Events #Slots 基本使用 通过v-model绑定value初始值&#xff0c;此值是双向绑定的&#xff0c;无需在回调中将返回的数值重…...