
Terminal - Commands using sed - 992 results
systemd-analyze plot | curl -sF file1=@- http://ompldr.org/upload | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\<\/a\>" | sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@'
This is sample output - yours may be different.
http://ompldr.org/vZ2dyOA
Useful for figuring out which services are lagging the boot time on the system.
svn log -l1000 SVN_URL | sed -n '/USERNAME/,/-----$/ p'
This is sample output - yours may be different.
find . -type f -regex '.*html$' -exec sed -i 's/\xEF\xBB\xBF//' '{}' \;
This is sample output - yours may be different.
cd ~/.msf4/loot && cat *mscache* | cut -d '"' -f 2,4 | sed s/\"/\:/g | tr -cd '\11\12\40-\176' | grep -v Username | cut -d : -f 1,2 | awk -F':' '{print $2,$1}' | sed 's/ /:/g' > final.dcc.hash
This is sample output - yours may be different.
cat dump.sql | sed -n -e '/Table structure for table .table1./,/Table structure for table .table2./p'
This is sample output - yours may be different.
Given a dump.sql file, extract table1 creation and data commands. table2 is the one following table1 in the dump file. You can also use the same idea to extract several consecutive tables.
vim `git status --porcelain | sed -ne 's/^ M //p'`
This is sample output - yours may be different.
The option --porcelain makes the output of git easier to parse.
This one-liner may not work if there is a space in the modified file name.
wget --no-check-certificate https://code.google.com/p/msysgit/downloads/list -O - 2>nul | sed -n "0,/.*\(\/\/msysgit.googlecode.com\/files\/Git-.*\.exe\).*/s//http:\1/p" | wget -i - -O Git-Latest.exe
This is sample output - yours may be different.
This command should be copy-pasted in Windows, but very similar one will work on Linux.
It uses wget and sed.
find . -type f |egrep '^./.*\.' |sed -e "s/\(^.*\.\)\(.*$\)/\2/" |sort |uniq
This is sample output - yours may be different.
bak
bat
cfg
conf
csv
doc
exe
exe_back
pyc
sql
txt
xls
find files recursively from the current directory, and list the extensions of files uniquely
hl-nonprinting () { local C=$(printf '\033[0;36m') B=$(printf '\033[0;46m') R=$(printf '\033[0m') np=$(env printf "\u00A0\uFEFF"); sed -e "s/\t/${C}▹&$R/g" -e "s/$/${C}⁋$R/" -e "s/[$np]/${B}& $R/g";}
This is sample output - yours may be different.
$ env printf '\uFEFFfoo\u00A0bar\nfie\tfum'|hl-nonprinting
foo? bar⁋
fie▹ fum⁋
Can't see it here, but the non-breaking space is highlighted :)
Of course,
cat -t -e
achieves something similar, but less colourful.
Could add more code points from https://en.wikipedia.org/wiki/Space_%28punctuation%29#Spaces_in_Unicode
hl-nonprinting () { local C=$(printf '\033[0;36m') R=$(printf '\033[0m'); sed -e "s/\t/${C}▹&$R/g" -e "s/$/${C}⁋$R/";}
This is sample output - yours may be different.
$ echo -e 'foo\tbar\nfie\tfum'|hl-nonprinting
foo▹ bar⁋
fie▹ fum⁋
I don't think it's possible to give a (background) colour to the tab itself, since a tab is, IIUC, simply a command to the terminal to move to the right. Nevertheless, this "highlighting" can be helpful when working with tab-separated files.
sed -e "s,/\+$,," -e "s,^/\+,," file.txt
This is sample output - yours may be different.
There can be more than one trailing slash, all of them will be removed.
sed -i 'g/text/d' <filename>
This is sample output - yours may be different.
curl -qsL http://checkip.dyn.com | sed -E "s/^.*Address: ([0-9\.]+).*$/\1/"
This is sample output - yours may be different.
Retrieves the current WAN ipv4 address via checkip.dyn.com.
tail -f /var/log/messages.log | while read line ; do echo $line | cut -d \ -f5- | sed s/\\[[0-9]*\\]// | espeak ; done
This is sample output - yours may be different.
(comment:) $ sed -i 's/blah.*/#&/g' file.txt (uncomment:) $ sed -i 's/.\(blah*.\)/\1/g' file.txt
This is sample output - yours may be different.
comment:
$ sed -i 's/blah.*/#&/g' file.txt
$ cat file.txt
dugh
#blah
adfas
sdfkb
#blah
asdfkk
#blah
uncomment:
$ sed -i 's/.\(blah*.\)/\1/g' file.txt
$cat file.txt
dugh
blah
adfas
sdfkb
blah
asdfkk
blah
seq 2 100 | factor | sed '/ .* / d ; s/:.*//'
This is sample output - yours may be different.
p=1 ; lynx -source http://www.lipsum.com/feed/xml?amount=${p} | grep '<lipsum>' -A$(((p-1))) | perl -p -i -e 's/\n/\n\n/g' | sed -n '/<lipsum>/,/<\/lipsum>/p' | sed -e 's/<[^>]*>//g'
This is sample output - yours may be different.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat tincidunt diam ut lobortis. Aenean sed dolor nibh, eget consequat purus. Curabitur luctus nibh nec velit dignissim ultrices. Mauris id elit ac diam tempus facilisis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin euismod consectetur lorem, sit amet pellentesque felis elementum a. Vivamus congue nulla et lorem convallis rutrum. Curabitur dapibus aliquam nunc sed vestibulum. In at ornare mauris. Integer congue sem turpis. In at velit at neque facilisis facilisis a egestas justo. Proin gravida diam sed metus elementum egestas. Maecenas et enim vel dolor dictum faucibus. Sed ultrices rutrum nisi, vitae rutrum tortor consequat ac. Maecenas at nunc in neque vestibulum varius.
This fixes the extra lines you get when you request only 1 paragraph using a little bit of grep. Just set p to the number of paragraphs you want.
function ip-where { wget -qO- -U Mozilla http://www.ip-adress.com/ip_tracer/$1 | html2text -nobs -style pretty | sed -n /^$1/,/^$/p;}
This is sample output - yours may be different.
userfriendly.org IP address location & more:
Host of the IP: userfriendly.org[Whois] [Reverse_IP]
Host IP [?]: 98.124.60.211
[Whois] [Reverse_IP]
IP country code: CA
IP address country: ip address flag Canada
IP address state: Ontario
IP address city: Ottawa
IP postcode: k1v9c3
IP address latitude: 45.4167
IP address longitude: -75.7000
ISP of this IP [?]: Server North
Organization: Server North
Local time in Canada: 2012-10-22 16:37
Tries to avoid the fragile nature of scrapers by looking for user-input in the output as opposed to markup or headers on the web site.
diff ../source-dir.orig/ ../source-dir.post/ | grep "Only in" | sed -e 's/^.*\:.\(\<.*\>\)/\1/g' | xargs rm -r
This is sample output - yours may be different.
Good for when your working on building a clean source install for RPM packaging or what have you. After testing, run this command to compare the original extracted source to your working source directory and it will remove the differences that are created when running './configure' and 'make'.
dpkg --list | rgrep ii | cut -d" " -f3 | sed ':a;N;$!ba;s/\n/ /g' | sed 's/^\(.\)/apt-get install \1/'
This is sample output - yours may be different.
apt-get install acl adduser anthy-common apt apt-utils aptitude authbind avahi-daemon base-files base-passwd bash bind9-host binutils bsdmainutils bsdutils busybox bzip2 ca-certificates ca-certificates-java collectd collectd-core coreutils cpio cpp cpp-4.4 cron curl dash dbus debconf debconf-i18n debian-archive-keyring debianutils deborphan defoma dhcpcd dialog diffutils dmidecode dmsetup dnsutils dpkg dstat e2fslibs e2fsprogs emacs emacs23 emacs23-bin-common emacs23-common emacsen-common fancontrol file findutils firmware-linux-free fontconfig fontconfig-config fping gcc gcc-4.4 gcc-4.4-base gconf2-common geoip-database gettext-base gnupg gpgv grep groff-base grub grub-common grub-pc gsfonts gsfonts-x11 gzip hicolor-icon-theme hostname htop ifupdown info initramfs-tools initscripts insserv install-info iproute iptables iputils-ping java-common joe klibc-utils less lftp libaccess-bridge-java libaccess-bridge-java-jni libacl1 libanthy0 libasound2 libasyncns0 libatk1.0-0 libatk1.0-data libattr1 libavahi-client3 libavahi-common-data libavahi-common3 libavahi-core7 libbind9-60 libblkid1 libboost-iostreams1.42.0 libbsd0 libbz2-1.0 libc-bin libc-dev-bin libc6 libc6-dev libcairo2 libcap-ng0 libcap2 libcomerr2 libcommons-collections3-java libcommons-dbcp-java libcommons-pool-java libcroco3 libcups2 libcurl3 libcurl3-gnutls libcurses-perl libcurses-ui-perl libcwidget3 libdaemon0 libdatrie1 libdb4.7 libdb4.8 libdbi0 libdbi1 libdbus-1-3 libdbus-glib-1-2 libdevmapper1.02.1 libdns69 libecj-java libedit2 libept1 libesmtp6 libevtlog0 libexpat1 libflac8 libfont-freetype-perl libfontconfig1 libfontenc1 libfreetype6 libfribidi0 libgcc1 libgconf2-4 libgcrypt11 libgd2-noxpm libgdbm3 libgeoip1 libgif4 libglib2.0-0 libglib2.0-data libgmp3c2 libgnutls26 libgomp1 libgpg-error0 libgpm2 libgsf-1-114 libgsf-1-common libgssapi-krb5-2 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libhal1 libice-dev libice6 libidl0 libidn11 libisc62 libisccc60 libisccfg62 libjasper1 libjpeg62 libk5crypto3 libkeyutils1 libklibc libkrb5-3 libkrb5support0 liblcms1 libldap-2.4-2 liblocale-gettext-perl liblockfile1 libltdl7 liblua5.1-0 liblwres60 liblzma2 libm17n-0 libmagic1 libmemcached10 libmodbus5 libmpfr4 libmysqlclient16 libncurses5 libncursesw5 libnet-snmp-perl libnet1 libnewt0.52 libnfnetlink0 libnl1 libnspr4-0d libnss-mdns
for f in *; do fn=`echo $f | sed 's/\(.*\)\.\([^.]*\)$/\1\n\2/;s/\./-/g;s/\n/./g'`; mv $f $fn; done
This is sample output - yours may be different.
Image.1.2.png --> Image-1-2.png
This command can rename all files in a folder changing all the dots in the filename for dashes, but respecting the final dot for the extension.
git for-each-ref --sort='-authordate' --format='%(refname)%09%(authordate)' refs/heads | sed -e 's-refs/heads/--'
This is sample output - yours may be different.
source <(egrep '^#define EX_.*' /usr/include/sysexits.h | sed -e 's/#define/declare -r/g' | sed 's/\//#/g' | sed -e 's/\s\{1,\}/ /g' | sed -e 's/ \([0-9]\)/\=\1/'g )
This is sample output - yours may be different.
declare -r EX__BASE=64 #* base value for error messages *#
declare -r EX_USAGE=64 #* command line usage error *#
declare -r EX_DATAERR=65 #* data format error *#
declare -r EX_NOINPUT=66 #* cannot open input *#
declare -r EX_NOUSER=67 #* addressee unknown *#
declare -r EX_NOHOST=68 #* host name unknown *#
declare -r EX_UNAVAILABLE=69 #* service unavailable *#
declare -r EX_SOFTWARE=70 #* internal software error *#
declare -r EX_OSERR=71 #* system error (e.g., can't fork) *#
declare -r EX_OSFILE=72 #* critical OS file missing *#
declare -r EX_CANTCREAT=73 #* can't create (user) output file *#
declare -r EX_IOERR=74 #* input#output error *#
declare -r EX_TEMPFAIL=75 #* temp failure; user is invited to retry *#
declare -r EX_PROTOCOL=76 #* remote error in protocol *#
declare -r EX_NOPERM=77 #* permission denied *#
declare -r EX_CONFIG=78 #* configuration error *#
declare -r EX__MAX=78 #* maximum listed value *#
Use meaningful exit codes
change "source" to "cat" to view output instead of assigning
This is sample output - yours may be different.
cp foo.txt foo.txt.tmp; sed '$ d' foo.txt.tmp > foo.txt; rm -f foo.txt.tmp
This is sample output - yours may be different.
sed '$ d' foo.txt.tmp
...deletes last line from the file