9,292 reputation
11738
bio website
location
age
visits member for 2 years, 4 months
seen 6 hours ago

浪人


8h
revised how to split file and lines
deleted 2 characters in body
8h
answered how to split file and lines
Dec
25
comment What command(s) will feed a tab-delimited text file and cut each line to 80 characters?
You could try pr from coreutils: pr -1 -t -l200 -W80 file. Increase/decrease the page length (number after -l) as per your need.
Dec
24
comment GUI running without $XAUTHORITY being defined, but not for root
You have to run the (zenity/notify) command as the user currently active on DISPLAY :0.0 e.g. DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-dgVfhNaG5L,guid=e0fea52a090f1‌​9174e207c4854691ae1' DISPLAY=:0.0 su don -c "zenity --error --text 'error'". Works fine here.
Dec
24
comment GUI running without $XAUTHORITY being defined, but not for root
All right but have you checked whether your system uses DBUS_SESSION_BUS_ADDRESS or not ?
Dec
24
comment UID less than 500 is getting created even after specifying UID_MIN as 500 in /etc/login.defs
Isn't hdfs a system user ? You have to define SYS_UID_MIN for system users: man useradd | grep -A5 ' --system'
Dec
24
comment Print first and last line of all files in folder
No need to echo+cat and echo+tac, you could just sed -n '/^[[:space:]]*$/!{s/^/first line: /p;q}' "$file" and sed -n '/^[[:space:]]*$/!h;$!d;g;s/^/last line: /p' "$file"
Dec
23
comment Print first and last line of all files in folder
As per the question, OP wants to print the "first & last lines that aren't whitespace". So you could do something like grep -v '^\s*$' "$file" | head -n 1 and grep -v '^\s*$' "$file" | tail -n 1 to get the expected result.
Dec
23
comment Print first and last line of all files in folder
I know that. I meant without the "echo file: $file" part, if you read the code in my comment. Also, don't forget to quote the last $file otherwise your solution will fail for file names with spaces and stuff.
Dec
23
comment Print first and last line of all files in folder
I think you could use a one-liner... actually a two-liner as there's a new line after the backslash: for file in file.log.*; do sed -n '/[^[:space:]]/ {h;s/^/file: '"$file"'\ enter a new line here first line: /p;:loop;${g;s/^/last line: /p};n;/[^[:space:]]/h; b loop}' "$file"; done
Dec
23
comment How to run a command only if sed replace strings
Or grep -q '^# deb.*multiverse' /etc/apt/sources.list && sed blah blah && apt-get update.
Dec
23
comment Any tool or command can detect flash disk or SSD memory type?
How do I know if my SSD is SLC or MLC ?
Dec
23
reviewed Approve Unable to trap “CTRL+C” within kickstart “%pre” bash script
Dec
22
revised How can I use Adwaita Dark for all applications in Gnome 3?
the question is not specific to Gnome 3.4
Dec
22
answered Where may I find a reference scheme for GNOME 3.14's theming?
Dec
22
revised What is a good alternative to iTunes on Linux?
replaced link to old page with links to recent pages that provide more alternatives
Dec
22
revised Use sed or awk to join lines in a certain pattern?
added 117 characters in body
Dec
22
comment How can I double the newlines in an output stream
A fine answer that shouldn't be overlooked.
Dec
21
comment sed with multiple expression for in-place arguement
If your files are similar to the example above (i.e they follow the same pattern) you can do it with a single substitution: sed - i 's/Some\(.*\)item/any\1stuff/' file
Dec
21
answered Split: how to split into different percentages?