- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Ubuntu 16.04
bash 4.4.20
我想清理我的一些游戏配置,以便信息整齐地存储在列中。每行都有类似的内容:
somegamevar "0" // This here explains the stuff on the left
anothervar 9 // Sometimes the value is not in doublequotes
当一个文件没有整齐地排列时,它会变得困惑,所以我们在编辑器中花费了大量时间。这是其中一个文件的一部分。
mp_death_drop_defuser "1" // Drop defuser on player death
mp_death_drop_grenade "2" // Which grenade to drop on player death: 0=none, 1=best, 2=current or best
mp_death_drop_gun "1" // Which gun to drop on player death: 0=none, 1=best, 2=current or best
mp_defuser_allocation "0" // How to allocate defusers to CTs at start or round: 0=none, 1=random, 2=everyone
mp_do_warmup_period "1" // Whether or not to do a warmup period at the start of a match.
mp_forcecamera "1" // Restricts spectator modes for dead players
mp_force_pick_time "160" // The amount of time a player has on the team screen to make a selection before being auto-teamed
mp_free_armor "0" // Determines whether armor and helmet are given automatically.
mp_freezetime "12" // How many seconds to keep players frozen when the round starts
mp_friendlyfire "1" // Allows team members to injure other members of their team
mp_halftime "1" // Determines whether or not the match has a team-swapping halftime event.
mp_halftime_duration "15" // Number of seconds that halftime lasts
mp_join_grace_time "30" // Number of seconds after round start to allow a player to join a game
mp_limitteams "0" // Max # of players 1 team can have over another (0 disables check)
mp_logdetail "3" // Logs attacks. Values are: 0=off, 1=enemy, 2=teammate, 3=both)
mp_match_can_clinch "1" // Can a team clinch and end the match by being so far ahead that the other team has no way to catching up
mp_match_end_restart "1" // At the end of the match, perform a restart instead of loading a new map
mp_maxmoney "16000" // maximum amount of money allowed in a player's account
mp_maxrounds "30" // max number of rounds to play before server changes maps
mp_molotovusedelay "0" // Number of seconds to delay before the molotov can be used after acquiring it
mp_overtime_enable "1" // Use overtime rules to determine winner
mp_overtime_maxrounds "10"
mp_overtime_startmoney "16000"
mp_playercashawards "1" // Players can earn money by performing in-game actions
mp_playerid "0" // Controls what information player see in the status bar: 0 all names; 1 team names; 2 no names
mp_playerid_delay "0.5" // Number of seconds to delay showing information in the status bar
mp_playerid_hold "0.25" // Number of seconds to keep showing old information in the status bar
mp_round_restart_delay "5" // Number of seconds to delay before restarting a round after a win
mp_roundtime "1.75" // How many minutes each round takes.
mp_roundtime_defuse "1.75" // How many minutes each round takes on defusal maps.
mp_solid_teammates "1" // Determines whether teammates are solid or not.
mp_startmoney "800" // amount of money each player gets when they reset
mp_teamcashawards "1" // Teams can earn money by performing in-game actions
mp_timelimit "0" // game time per map in minutes
mp_tkpunish "0" // Will a TK'er be punished in the next round? {0=no, 1=yes}
mp_warmuptime "1" // If true, there will be a warmup period/round at the start of each match to allow
mp_weapons_allow_map_placed "1" // If this convar is set, when a match starts, the game will not delete weapons placed in the map.
mp_weapons_allow_zeus "1" // Determines whether the Zeus is purchasable or not.
mp_win_panel_display_time "15" // The amount of time to show the win panel between matches / halfs
spec_freeze_time "5.0" // Time spend frozen in observer freeze cam.
spec_freeze_panel_extended_time "0" // Time spent with the freeze panel still up after observer freeze cam is done.
sv_accelerate "5.6" // ( def. "10" ) client notify replicated
sv_allow_votes "0" // Allow voting?
sv_allow_wait_command "0" // Allow or disallow the wait command on clients connected to this server.
sv_alltalk "0" // Players can hear all other players' voice communication, no team restrictions
sv_alternateticks "0" // If set, server only simulates entities on even numbered ticks.
sv_cheats "0" // Allow cheats on server
sv_clockcorrection_msecs "15" // The server tries to keep each player's m_nTickBase withing this many msecs of the server absolute tickcount
sv_consistency "0" // Whether the server enforces file consistency for critical files
sv_contact "0" // Contact email for server sysop
sv_damage_print_enable "1" // Turn this off to disable the player's damage feed in the console after getting killed.
sv_dc_friends_reqd "0" // Set this to 0 to allow direct connects to a game in progress even if no presents
sv_deadtalk "1" // Dead players can speak (voice, text) to the living
sv_forcepreload "0" // Force server side preloading.
sv_friction "4.8" // World friction.
sv_full_alltalk "0" // Any player (including Spectator team) can speak to any other player
sv_gameinstructor_disable "1" // Force all clients to disable their game instructors.
sv_ignoregrenaderadio "0" // Turn off Fire in the hole messages
sv_kick_players_with_cooldown 0 // (0: do not kick; 1: kick Untrusted players; 2: kick players with any cooldown)
sv_kick_ban_duration "0" // How long should a kick ban from the server should last (in minutes)
sv_lan "0" // Server is a lan server ( no heartbeat, no authentication, no non-class C addresses )
sv_log_onefile "0" // Log server information to only one file.
sv_logbans "1" // Log server bans in the server logs.
sv_logecho "1" // Echo log information to the console.
sv_logfile "1" // Log server information in the log file.
sv_logflush "0" // Flush the log file to disk on each write (slow).
sv_logsdir "logfiles" // Folder in the game directory where server logs will be stored.
sv_maxrate "0" // min. 0.000000 max. 30000.000000 replicated Max bandwidth rate allowed on server, 0 == unlimited
如果没有第三列,
column -t
会很棒,但第三列很重要。
所以这是预期的结果:
第 1 列和第 2 列相互隔开几个空格。第 3 列从第 70 个字符开始。
sv_alltalk "0" // Players can hear all other players voice communication, no team restrictions
sv_alternateticks "0" // If set, server only simulates entities on even numbered ticks.
sv_cheats "0" // Allow cheats on server
sv_clockcorrection_msecs "15" // The server tries to keep each players m_nTickBase withing this many msecs of the server absolute tickcount
sv_consistency "0" // Whether the server enforces file consistency for critical files
sv_contact "0" // Contact email for server sysop
sv_damage_print_enable "1" // Turn this off to disable the players damage feed in the console after getting killed.
sv_dc_friends_reqd "0" // Set this to 0 to allow direct connects to a game in progress even if no presents
sv_deadtalk "1" // Dead players can speak (voice, text) to the living
sv_forcepreload "0" // Force server side preloading.
sv_friction "4.8" // World friction.
sv_full_alltalk "0" // Any player (including Spectator team) can speak to any other player
sv_gameinstructor_disable "1" // Force all clients to disable their game instructors.
sv_ignoregrenaderadio "0" // Turn off Fire in the hole messages
sv_kick_players_with_cooldown 0 // (0: do not kick; 1: kick Untrusted players; 2: kick players with any cooldown)
sv_kick_ban_duration "0" // How long should a kick ban from the server should last (in minutes)
sv_lan "0" // Server is a lan server ( no heartbeat, no authentication, no non-class C addresses )
sv_log_onefile "0" // Log server information to only one file.
sv_logbans "1" // Log server bans in the server logs.
sv_logecho "1" // Echo log information to the console.
sv_logfile "1" // Log server information in the log file.
sv_logflush "0" // Flush the log file to disk on each write (slow).
sv_logsdir "logfiles" // Folder in the game directory where server logs will be stored.
sv_maxrate "0" // min. 0.000000 max. 30000.000000 replicated Max bandwidth rate allowed on server, 0 == unlimited
正如您在上面看到的,第 1 列和第 2 列彼此靠近,第 3 列从第 70 列开始整齐地位于右侧。
最佳答案
$ cat tst.awk
NR==FNR {
wid = (length($1) > wid ? length($1) : wid)
next
}
NF {
hd = sprintf("%-*s%3s%s", wid, $1, "", $2)
tl = ( (s=index($0,"//")) ? substr($0,s) : "")
$0 = sprintf("%-69s%s", hd, tl)
}
{ print }
$ awk -f tst.awk file file
mp_death_drop_defuser "1" // Drop defuser on player death
mp_death_drop_gun "1" // Which gun to drop on player death: 0=none, 1=best, 2=current or best
mp_friendlyfire "1" // Allows team members to injure other members of their team
mp_halftime "1" // Determines whether or not the match has a team-swapping halftime event.
mp_overtime_startmoney "16000"
mp_playercashawards "1" // Players can earn money by performing in-game actions
sv_alltalk "0" // Players can hear all other players' voice communication, no team restrictions
sv_cheats "0" // Allow cheats on server
sv_forcepreload "0" // Force server side preloading.
原答案:
这将按照您的要求从第 3 列的字符位置 60 开始:
awk '
s = index($0,"//") {
hd = substr($0,1,s-1)
sub(/[[:space:]]+$/,"",hd)
$0 = sprintf("%-59s%s",hd,substr($0,s))
}
1' file
例如给出这个输入:
$ cat file
mp_death_drop_defuser "1" // Drop defuser on player death
mp_death_drop_gun "1" // Which gun to drop on player death: 0=none, 1=best, 2=current or best
mp_friendlyfire "1" // Allows team members to injure other members of their team
mp_halftime "1" // Determines whether or not the match has a team-swapping halftime event.
mp_overtime_startmoney "16000"
mp_playercashawards "1" // Players can earn money by performing in-game actions
sv_alltalk "0" // Players can hear all other players' voice communication, no team restrictions
sv_cheats "0" // Allow cheats on server
sv_forcepreload "0" // Force server side preloading.
$ awk 's=index($0,"//"){hd=substr($0,1,s-1); sub(/[[:space:]]+$/,"",hd); $0=sprintf("%-59s%s",hd,substr($0,s))} 1' file
mp_death_drop_defuser "1" // Drop defuser on player death
mp_death_drop_gun "1" // Which gun to drop on player death: 0=none, 1=best, 2=current or best
mp_friendlyfire "1" // Allows team members to injure other members of their team
mp_halftime "1" // Determines whether or not the match has a team-swapping halftime event.
mp_overtime_startmoney "16000"
mp_playercashawards "1" // Players can earn money by performing in-game actions
sv_alltalk "0" // Players can hear all other players' voice communication, no team restrictions
sv_cheats "0" // Allow cheats on server
sv_forcepreload "0" // Force server side preloading.
关于bash - 如何重新定位每行的第三个字符串以从同一行的第 n 个字符开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63964915/
我必须从我的网站中删除()一些iem,然后将它们追加()回来,但是当我追加它们时,它们出现在不同的地方,而我希望它们完全显示在它们以前的同一个地方是。 有什么解决办法吗? 这是一个沙箱,请随意更新(注
一个。图片 (960x7)b. div(宽度:960,填充:10) 我想定位 (a),使其距顶部 50 像素,居中。我想将 (b) 放置在 (a) 的正下方,没有空格。 我的 CSS 如下: @cha
放置某物的正确方法是什么?我有一个在中心显示博客文章的 div。 "" rel="bookmark"> BY LOUIS MOORE ON " pubdate>
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭1
我已经成功地使用了 position:fixed 设置 CSS/CSS3 并且工作得很好! 我几天前看到了这个,想知道他们是如何实现向下滚动时发生的效果的,菜单栏在滚动前处于一个位置,然后转到顶部并自
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improv
接口定义 能够对于文字、段落乃至任何元素的精准定位 并做出增删改查,都是在开发一款富文本编辑器时一项最基本也是最重要的功能之一。让我们先来看看Slate中对于如何在文档树中定位元素是怎么定义的
例如,使用 WPF 在选项卡控件的最左上角定位三个 tabitem 和在最右上角定位一个 tabitem 的正确方法是什么? 我尝试通过更改边距将第四个 tabitem 向右移动,但这并没有产生好的结
我正在尝试使用 Javascript 创建一个跟随鼠标在页面上移动的东西。我希望它是米老鼠,我希望他的眼睛跟随鼠标移动他的眼球...这是我到目前为止的代码(从网络上的各个地方收集,因此归功于编写该部分
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 9 年前。 Improve
我试图将两个按钮放置在左上角。但它们始终位于顶部中心。 我已经尝试过这个: jp = new JPanel(); jp.setLayout(new GridBagLayout()); GridBagC
我在使用 JQuery 向下滑动功能时遇到问题。我可以让它正常工作,但是我向下滑动的元素的位置会根据视口(viewport)的大小而变化。我想做的是将它与它滑动的元素联系起来。 This JSfidd
我正在尝试创建一个棋盘,并将其放置在屏幕中间,但到目前为止我无法将它直接放在中间。我不想将位置硬编码到屏幕上,因为我要处理不同的屏幕尺寸。 var winsize = cc.director.
我正在尝试从 mysql 中的 2 个字符串点之间提取数据,我的示例脚本是 'otherdata&p1=textneeded&otherdata' 我需要拉出“textneeded”位,“P1=”是起
如何在 JavaFX 中设置按钮的位置?我的代码: bZero = new Button(); bZero.setPrefSize(45, 20); mainPane.getChildren().ad
我有一个 iPhone 应用程序,我可以在其中显示一系列图像。当用户点击图像时,我需要将该图像带到第一个位置,表明它是所选图像。我可以通过子类化实现 uiscrollview 中的点击。但是我无法将
在下图中,它显示了一个image、textbox 和一个css menu image 我的 CSS 菜单非常完美。我终于按照我需要的方式得到了它。我的问题是我需要导航栏中央的文本框,然后我需要我的图像
我必须创建一个看起来像这样的 div id为2的div应该出现在图片的右下角,图片的大小不固定id=2的div应该应用什么css id =1 的 div 没有定义位置,所以使用默认值,图像也是
如何将我的文本和图像对齐在同一行? 每当我使用 padding 或 margins 时,它就会崩溃到我正在使用的圆形图像中。 #alignPhoto { padding-right: 50px;
简单的问题,如何定位具有整个页面引用的元素? 在我的例子中,我在标题中得到了一个 float 图像,然后是 2 组标题。当我使用时: text-align: center; 它使用图像宽度端和页面其余
我是一名优秀的程序员,十分优秀!