Skip to main content
Home
term:~# less tar.gz.ro

Main navigation

  • Home
    • My Yard Projects
  • AIX World
    • AIX Commands
    • HACMP Commands
    • HMC Commands
    • How to assign disks to AIX partition via VIO
    • Misc stuff
    • NIM (Network Installation Management)
    • Virtual I/O (VIO)
  • Apple World
    • News
    • Tips & Tricks
    • iOS
  • CygWin World
    • CygWin Tips and Tricks
    • Cygwin: clone disk with dd
    • Cygwin: how to have multiple tabs in Cygwin's Mintty
    • Cygwin: start and enable sshd
    • config.guess: unable to guess system type
  • ESXi World
    • ESXi 7: Create VMFS Partition Via Command Line
    • ESXi : A bunch of useful commands and information
    • ESXi: How to change the hostname of an ESXi host
    • ESXi: how to change the MTU of vmkernek (vmk) interface (when UI fails)
    • ESXi: how to resize the OS partition
    • How to create a bootable USB installer of ESXi 7.0
  • Games
    • Assetto Corsa Rally vs Real Life – La Bollène-Vésubie → Col de Turini | Monte-Carlo Rally
    • Assetto Corsa Rally – Early Access Deep Dive
    • Diablo 3 & Reaper of Souls tips
    • EA Sports WRC Time Trial Locations and Stages
    • EA Sports WRC vs Assetto Corsa Rally | Visual Comparison (Gravel, Asphalt, Wet, Night, Snow)
    • Global Chip Shortage? Build this oddity: PC From 2009 With GeForce GTX 1050ti 4G
    • Left4Dead Lan Play
    • Live Sessions
    • Mafia II Joe's Adventures - Playboy Locations
  • HP-UX World
    • Boot into HPUX L2000
    • How to increase the size of a filesystem in LVM
    • Miscellaneous
    • Performance tools
    • Working with HP VM
  • Hardware
    • 5 Months with iPhone 15 Pro: Not PERFECT But... Must See. From Gaming to ProRes Requirements.
    • Apple Watch Series 9? Not Yet! I Still Love My "Seven of Nine" 19 months later
    • Asus ROG Sheath in 2024: a HUGE Mousepad, Bigger Than Logitech G840 XL
    • Choose Your Perfect Mic / Lavalier | AIQIU M31 vs. Boya BY-M3/BY-M2 & Puluz PU425
    • DJI Mic Mini 2 – Real-World Review and Testing
    • How I Test Mousepads: Glide, Control, and Surface Noise Explained
    • How to build a 25U 600x600 Server Rack
    • I Tested Creative Pebble V2 on My Sim Rig – Surprising Results!
    • Icy Box IB-3805-C31 speed test
    • Is the RX 9060 XT Mercury Class Worth It? Silent Power Meets Real Gameplay
    • Logitech Pro X Wired Gaming Headset (2nd gen): review + mic test with G HUB on Windows 11 and macOS
    • Logitech RS H-Shifter - Amazing Feel, But There’s a Catch (As Always)
    • Mousepad Logitech G840
    • PX8 S2 – A Journey Through Sound, Expectations and Reality
    • Play Steam Games on iPhone with Backbone One Playstation Edition gen2 USB-C / Steam Deck Alternative
    • Qnap TR-004 short review - working with linux
    • Razer Gigantus V2 XXL – 5 Months Later (Still Worth It?)
    • Samsung 870 QVO 2TB: Speed Tests and comparison with Adata SU650 and Kingston K600
    • Server-Ready MS-01 - A Small PC with Everything: SFP+, USB4, 2.5gbps LAN, Enterprise SSD, TPM 2.0
    • The TCL 34R83Q is Insane
    • The TCL 34R83Q is Insane… But There’s a Catch! Honest Review About a Real Product! Read Description.
    • The one with APC Back-UPS BE850G2-GR: Charge Whatever With It, From Phone to Computer And BEYOND :D
    • Thermaltake Pure 20 fan - HUGE and quiet!
    • Ubiquiti EdgeRouter X lift off
    • VIOFO A139 Quad HD Dash Camera - 3 Channels Camera in a 2 Channels Package. Confused?
    • Why Bluetooth Headphones Switch to MONO When Using the Microphone?
    • Why the Logitech PRO Racing Wheel Made Me a Better Driver
  • Home
  • Linux World
    • Alternative to finger command? Sure: pinky :)
    • Backup/restore/reinstall tips
    • Copy one file in linux with progress bar, using pv
    • DNSKEY: verify failed due to bad signature (keyid=19297): RRSIG has expired
    • DRBD: How to replace drbd backend devices
    • Debian 11: Unable to locate package glances
    • Debian 13: missing last command
    • Debian Bullseye (11): zpool command missing
    • Debian DRBD: How to resize drbd and OCFS2 online
    • Debian DRBD: How to resize drbd volume on top of LVM
    • Debian DRBD: Tips, Tricks and Commands
    • Debian Heartbeat: Commands, Tips and Tricks
    • Debian Heartbeat: STONITH errors when configuring CRM cluster
    • Debian Jessie: how to enable and start OpenVPN
    • Debian Tips & Tricks
    • Debian on mac mini: Core temperature above threshold, cpu clock throttled
    • Debian: Can't locate LWP/UserAgent.pm in @INC
    • Debian: HA (cluster) NFS with DRBD and Heartbeat
    • Debian: How to install, configure and manage ZFS
    • Debian: How to split rc.local in rc.local.stop and rc.local.start
    • Debian: Install and configure AFP server
    • Debian: LVM on ISCSI not activated on reboot.
    • Debian: The repository does no longer have a Release file
    • Debian: add and configure VLAN
    • Debian: how to choose default kernel in grub2
    • Debian: how to create bonding device
    • Debian: install open-vm-tools
    • Debian: pdo_mysql.so: undefined symbol: pdo_parse_params in Unknown on line 0
    • Debian: reinstall zfs when changing the linux kernel
    • Debian: ssh key no longer works after upgrading to Debian version 9
    • Docker: Pi-Hole - Failed to set capabilities on file `/usr/bin/pihole-FTL' (Operation not supported)
    • Gnome: Clear "Open With" list
    • How to add a swap file in linux
    • How to add an ISCSI disk from linux server
    • How to add exfat support on RHEL 6
    • How to be sure network interfaces have always the same names
    • How to check which local device is assigned to which iscsi disk
    • How to configure GlusterFS with a volume replicated over 2 nodes
    • How to create an encrypted image
    • How to create bond device under linux
    • How to create/modify a file's timestamp
    • How to give more memory to Lotus Notes in Linux
    • How to install bind (name server) in chroot environment
    • How to install mplayer on RHEL 6
    • How to install openoffice 4.0.1 on Fedora 20/19/18, CentOS/Red Hat (RHEL) 6.5
    • How to install python 2.7 on Red Hat Enterprise Linux Workstation release 6.5 (Santiago)
    • How to modify the hostname on Linux
    • How to mount a HFS partition in linux as Read/Write?
    • How to properly configure oidentd for IRC connections
    • How to read MBR
    • How to remove LVM snapshots if you get message "Can't remove open logical volume"
    • How to setup OpenVPN server for iPhone
    • How to show UUID of a block device, including other attributes too
    • How to speed up things by using tmpfs (your memory)
    • How to switch from pc to efi and recreate boot partition
    • How to test ethernet speed with iperf
    • How to write CD or DVD under linux's console
    • ISCIS: remove disk from linux client
    • LVM
    • Linux Network Tips and Tricks
    • Linux: CPU utilization vs. load average
    • Linux: How to clear (delete) a GUID partition table (GPT)
    • Linux: TCP keepalive or not
    • Linux: Tuning network cards on Linux
    • Linux: how to check if the disk is SSD or not
    • Network Manager - get_secrets_cb(): Couldn't get connection secrets
    • RHEL6: yum update - package is a duplicate with package
    • RPM Tips and Tricks
    • ReiserFS: how to recover deleted files
    • ShellShock - Fix Bash on Debian Lenny
    • ShellShock - Fix Bash on Debian Squeeze
    • Spamassassin: eval/lookup failed: available_nameservers: No DNS servers available!
    • Start restricted graphical apps
    • Systemd startup order
    • Ubuntu: Fast Install With VMware Fusion
    • User Management
    • Using Mdadm
    • Wi-FI KO after upgrade to RHEL 6.5
    • ZFS: Convert a One Disk Pool in Two Disks Mirror
    • ZFS: cannot import 'whatever': no such pool available
    • how to resize iscsi volume in Linux
    • rc.openvpn for slackware
  • Solaris World
    • Tips & Tricks
  • Windows World
    • Active Directory Command Line (CMD) Tips & Tricks
    • Excel: extract text between two different characters
    • Excel: seconds in hours:minutes:seconds
    • PowerShell tips and tricks
    • Windows 7: How to repair boot partition
    • Windows 7: Steam not starting
    • Windows 7: how to disable/enable hibernation
    • Windows CMD commands
  • Tips & Tricks
    • Apache Tips & Tricks
    • Audio / Video *nix Command Line Tricks
    • Bombardier: How to use it to Download Boot Camp Drivers
    • Brigadier: How to use to Download Boot Camp Drivers
    • Citrix XEN: Install VM OS via CLI
    • Citrix Xen CLI Tips & Tricks
    • Citrix Xen: Connect to VM's VNC console
    • Citrix Xen: How to "migrate" VHD lv from one XEN to another with dd
    • Citrix Xen: How to attach an existing vdi to any virtual machine
    • Citrix Xen: How to rename a vm via command line
    • Citrix Xen: How to show vm information via command line
    • Citrix Xen: Modify VM memory value via CLI
    • Docker Tips and Tricks
    • Docker: Create a Custom Image
    • Docker: How to Check Which Docker Container is Using the Space in Linux
    • Docker: How to Run Your Own Docker Registry (e.g. Images Repository)
    • Docker: Install on Debian
    • Docker: Playing with consul
    • Docker: UNIX socket and TCP port
    • Docker: how to enable swap limit capabilities
    • Docker: how to increase php memory "the docker way"
    • Docker: syslog-ng setup
    • Executing commands remotely on multiple systems via SSH
    • FIO Perf Tool Nutshell
    • Flushing the ARP cache
    • FreeNAS console tricks
    • Gallery2 - Gd - How to create thumbnails with fixed width while keeping the aspect ratio (variable height)
    • Gallery2 - Imagemagick - How to create thumbnails with fixed width while keeping the aspect ratio (variable height)
    • Gallery2 - Netpbm - How to create thumbnails with fixed width while keeping the aspect ratio (variable height)
    • How to change the hostid of a Linux operating system
    • How to create a hash password from text
    • How to delete files or directories that contains special characters
    • How to display the output of a file without the blank lines
    • How to enable rstatd
    • How to encrypt a file in linux (or cygwin)
    • How to find out which process is using some port
    • How to login to youtube account via Apple TV if you have Google Authenticator enabled
    • How to resume failed scp transfer
    • How to rotate pdf files with pdftk tool
    • How to send a json from command line
    • How to use an LVM partition as VirtualBox disk
    • IBM DS System Storage common commands examples
    • ImageMagick Tricks
    • Logging ssh sessions
    • Merge mp3 files
    • Miscellaneous
    • MySQL Commands, Tips and Tricks
    • Nagios Stuff
    • Nagios: UNKNOWN: Drive S/N : No health status line found,
    • Networking - questions and answers
    • Oracle: How to connect to the listener and display a parameter's value
    • Oracle: How to list DBA users for a database
    • Oracle: dbfsize Header block magic number is bad
    • Oracle: display tablespace information with sizes
    • PHP: How to display in a table, information from a text file
    • Python: fake smtp server
    • Render Blocking JavaScript and CSS
    • Runlevels
    • SAP useful commands for UNIX administrator
    • SMF Tips and Tricks
    • Script to get memory usage of desired processes
    • Strings or File Manipulation
    • The Hard Link
    • Using Find Command
    • Using VI Editor
    • VirtualBox Tips&Tricks
    • VirtualBox: How to Add Serial Port for Linux Cluster Heartbeat Monitoring
    • VirtualBox: How to work with ISCSI disks
    • dsmc commands
    • iMessage “Waiting for Activation” Error on iPhone
  • Exclamation!
    • Bash CVE-2014-6278 CVE-2014-6277
    • Heartbleed Bug
    • PHP2Shell: Critical PHP Remote Code Execution Vulnerabilities
    • Ransomware KeRanger attached to Transmission app
    • Shellshock (CVE-2014-6271)
  • About This
    • Cookies, Cookies, Cookies!
  • Donate
User account menu
  • Log in
Popular content

Today's:

  • PHP2Shell: Critical PHP Remote Code Execution Vulnerabilities
  • Drupal 7 to Drupal 10 Migration and Configuration Notes
  • How to test ethernet speed with iperf
  • Assetto Corsa Rally vs Real Life – La Bollène-Vésubie → Col de Turini | Monte-Carlo Rally
  • €6,000 MacBook Pro: Should I Throw It Away After 6 Years?
  • AIX FS Commands
  • CygWin World
  • CygWin Tips and Tricks
  • How to shrink a reiserfs LVM partition
  • ESXi: How to create a bootable USB installer of ESXi 7.0

All time:

  • Linux Networking: How to disable/enable offload features, RX/TX checksum, scatter, gather and beyond
  • Tivoli Storage Manager Client Commands (dsmc commands)
  • Centrify Useful Commands and Information
  • Run ZIM on OS X and create Zim.app
  • How to be sure network interfaces have always the same names
  • Linux backup/restore/reinstall
  • How to add exfat support on RHEL 6
  • Mafia II Joe's Adventures - Playboy Locations
  • HMC commands
  • Command Line Software Update in MacOS

Last viewed:

  • PHP2Shell: Critical PHP Remote Code Execution Vulnerabilities
  • How to shrink a reiserfs LVM partition
  • How to test ethernet speed with iperf
  • OS X - How to change audio output from Menubar
  • Linux: keepalive or not
  • The TCL 34R83Q is Insane! But There’s a Catch. Honest Review About a Real Product. Read Description.
  • Error: CarbonHeaders is an obsolete port. Please uninstall it.
  • Drupal 7 to Drupal 10 Migration and Configuration Notes
  • EA Sports WRC vs Assetto Corsa Rally | Visual Comparison in Ultra Wide (Gravel, Asphalt, Wet, Night, Snow)
  • ESXi: How to create a bootable USB installer of ESXi 7.0

Breadcrumb

  1. Home

Strings or File Manipulation

Profile picture for user root
By root, 14 October, 2011

How to replace tab with newline:

gz@linux:~$ cat list
str1    str2    str3    str4    str5    str6    str7    str8
gz@linux:~$ cat list | tr '\t' '\n' >list2
gz@linux:~$ cat list2
str1
str2
str3
str4
str5
str6
str7
str8

How to get different parts of a string, for example with path and file name:

gz:tips# foo=/tmp/dir/filename.tar.gz
gz:tips# echo ${foo%/*}
/tmp/dir
gz:tips# echo ${foo##*/}
filename.tar.gz
gz:tips# echo ${foo%%.*}
/tmp/dir/filename
gz:tips# echo ${foo%.tar.gz}
/tmp/dir/filename
gz:tips# echo ${foo#*.}
tar.gz

How to rename multiple files, same name and different extension:

In this example below, I need to rename all win11* files into win11usb*.
fmbp16:win11usb.vmwarevm $ ls win11*
win11.nvram	win11.plist	win11.vmsd	win11.vmx	win11.vmxf
fmbp16:win11usb.vmwarevm $ for i in $(ls win11*); do mv ${i} win11usb.${i#*.}; done
fmbp16:win11usb.vmwarevm $ ls win11*
win11usb.nvram	win11usb.plist	win11usb.vmsd	win11usb.vmx	win11usb.vmxf
fmbp16:win11usb.vmwarevm $ 

How to find and rename recursively. First example is for files and second for directories:

gz:tips# for FILE in $(find . -type f -name "*foo*"); do NEW=`echo $FILE | sed -e 's/foo/bar/'`; mv "$FILE" "$NEW"; done
gz:tips# for DIR in $(find . -type d -name "*foo*"); do NEW=`echo $DIR | sed -e 's/foo/bar/'`; mv "$DIR" "$NEW"; done

How to display with awk from a desired column to the end. In the examples below we will display the free space for all vgs in AIX system:

root@gzaix:~# [color=green]for i in $(lsvg -o); do printf "$i ==>\t";lsvg $i| grep -i free| awk '{ print substr($0, index($0,$4)) }'; done[/color]
datavg06 ==>    FREE PPs:       3 (384 megabytes)
datavg ==>      FREE PPs:       489 (62592 megabytes)
datavg01 ==>    FREE PPs:       549 (70272 megabytes)
datavg04 ==>    FREE PPs:       4 (512 megabytes)
datavg03 ==>    FREE PPs:       109 (13952 megabytes)
datavg02 ==>    FREE PPs:       159 (20352 megabytes)
datavg07 ==>    FREE PPs:       4 (256 megabytes)
datavg08 ==>    FREE PPs:       125 (8000 megabytes)
datavg05 ==>    FREE PPs:       143 (18304 megabytes)
rootvg ==>      FREE PPs:       13 (1664 megabytes)

How to search for a string in multiple files on linux:

root@linux:~# find . -type f -print0 | xargs -0 grep -i book

How to search and replace a string in multiple files on linux:

root@linux:~# find . -type f -print0 | xargs -0 sed -i 's/book/BOOK/g'

How to search for directories with a specific number of files inside:

FILESCOUNT="1"; find . -maxdepth 1 -type d -exec bash -c "echo -ne ‘{}’; ls ‘{}’ | wc -l" \; | awk -v fc="$FILESCOUNT" ‘$NF==fc {print $0} END {print "The dirs above have " fc " files inside."}’

How to display the last column from an output:

root@aix:/ # lssrc -s nimsh
Subsystem         Group            PID          Status
 nimsh            nimclient                     inoperative
root@aix:/ # lssrc -s nimsh | awk '{print $NF}'
Status
inoperative

How to extract only numbers from a string with bash:

root@linux:~# [color=green]TEST="1238ksds98amnsa62knb2gi2v23v"[/color]
root@linux:~# [color=green]echo ${TEST//[!0-9]/}[/color]
123898622223
root@linux:~# [color=green]echo ${TEST//[^0-9]/}[/color]
123898622223

How to extract only numbers from a string with sed:

root@linux:~# [color=green]echo 1238ksds98amnsa62knb2gi2v23v | sed 's/[^0-9]//g'[/color]
123898622223

Passing variable to awk:

root@linux:~# [color=green]for i in 21684 26667 20991; do ps -ef | awk -v ss="$i" '$2 ~ ss { print }'; done[/color]
root     21684 10157  0 Nov22 tty1     00:00:00 -bash
root     26667     1  0 Nov22 ?        00:00:00 dhclient3 eth2
vbox     20991 20983  0 Oct24 ?        00:00:00 gnome-session
another example:
florian@florian:~$ [color=green]for i in 1 2 3 4 5; do echo $i | awk -v ss="awkvar$i" '{print ss" from "$0}'; done[/color]
awkvar1 from 1
awkvar2 from 2
awkvar3 from 3
awkvar4 from 4
awkvar5 from 5

How to count a string's characters:

root@linux:~$ STRING="12345"
root@linux:~$ echo "Chars: ${#STRING}"
Chars: 5

How to remove blank lines from a file using grep and awk:

root@linux:~# cat /tmp/test.txt
1234567890

abcde
fgh

ijklmn
root@linux:~# grep -v ^$ /tmp/test.txt
1234567890
abcde
fgh
ijklmn
root@linux:~# awk 'NF != 0 {print} ' /tmp/test.txt
1234567890
abcde
fgh
ijklmn

How to add a line after some string

(to add "BOOOOOOO!" if the line contains "abc" (first example) or if the line is "fgh" (second example)):
root@linux:~# awk '{print ; if ($0 ~ "abc") print "BOOOOOOO!"}' /tmp/test.txt
1234567890

abcde
BOOOOOOO!
fgh

ijklmn
root@linux:~# awk '{print ; if ($0 == "fgh") print "BOOOOOOO!"}' /tmp/test.txt
1234567890

abcde
fgh
BOOOOOOO!

ijklmn

How to transform a line from lowercase to uppercase with sed:

root@linux:~# sed 's/abcde/ABCDE/g' /tmp/test.txt
1234567890

ABCDE
fgh

ijklmn

How to split a string after the second delimiter with sed:

gz@linux:~$ echo "1:2:3:4:5:6:7:8:9" | sed "s/\([^:]*:[^:]*\):/\1\n/g"
1:2
3:4
5:6
7:8
9
or
gz@linux:~$ echo "1:2:3:4:5:6:7:8:9" | sed "s/[^:]*:[^:]*:/& /g" | sed "s/: /\n/g" 
1:2
3:4
5:6
7:8
9
or in ksh
gz@aix~# echo "1:2:3:4:5:6:7:8:9" | sed "s/\([^:]*:[^:]*\):/\1 /g" | tr " " "\n"
1:2
3:4
5:6
7:8
9

How to replace the 3rd same (repetitive) character with another:

srt@gz$ echo "00:21:26:400 --> 00:21:28:400" | sed "s/\([^00:]*:[^:]*:[^:]*\):/\1\,/g"
00:21:26,400 --> 00:21:28,400

How to convert uppercase to lowercase characters in a file with TR:

florian@florian:~$ cat b
ASLDJSLDJSLKJD
SLKJDLKSJDLK
SOIDUSOIDUOIS
SDOSDSJLD
florian@florian:~$ cat b | tr '[:upper:]' '[:lower:]' 
asldjsldjslkjd
slkjdlksjdlk
soidusoiduois
sdosdsjld
florian@florian:~$ cat b | tr '[A-Z]' '[a-z]'  
asldjsldjslkjd
slkjdlksjdlk
soidusoiduois
sdosdsjld

How to rename filenames in different order (for example files like "This is file 001.jpg" to "001 file is This.jpg"):

1. Put them to a file like ls.txt. 2. Run this script in the same directory.
#!/bin/bash
#
cat ls.txt | sed s/.jpg//g | while read line;
  do
	arr=($line)
	mv "${arr[0]} ${arr[1]} ${arr[2]} ${arr[3]}.jpg" "${arr[3]} ${arr[2]} ${arr[1]} ${arr[0]}.jpg"
done

How to calculate and display in AIX disk space in GB:

Total from bootinfo:
root@aix:~# [color=green]for i in $(lspv|awk '{print $1}' | xargs); do bootinfo -s $i; done | awk '{ s = s+$1/1024 } END { printf "Total disk space: %dGB\n",s }'[/color]
Total disk space: 4125GB
Total from lsvg info:
root@aix:~# [color=green]for i in $(lsvg -o); do lsvg $i| grep -i total| awk '{ print substr($0, index($0,$7)) }'; done | sed "s/[^0-9]//g" | awk '{ s = s+$1/1024 } END { printf "Total: %dGB\n",s }'[/color]
Total: 559GB
Total used and free from lsvg info:
root@aix:~# [color=green]for i in $(lsvg -o); do lsvg $i| grep -i free| awk '{ print substr($0, index($0,$7)) }'; done | sed "s/[^0-9]//g" | awk '{ s = s+$1/1024 } END { printf "Free: %dGB\n",s }'[/color]
Free: 20GB
root@aix:~# [color=green]for i in $(lsvg -o); do lsvg $i| grep -i used| awk '{ print substr($0, index($0,$6)) }'; done | sed "s/[^0-9]//g" | awk '{ s = s+$1/1024 } END { printf "Used: %dGB\n",s }'[/color]
Used: 538GB

How to search for files which contains a specific text within a tar archive:

root@aix:~# [color=green]for f in `ls archives*.tar.Z `; do echo $f; zcat $f | tar -tvf - | grep WHAT_TO_SEARCH_FOR; done;[/color]
archives_20141007.tar.Z
archives_20141006.tar.Z
archives_20141009.tar.Z
-rw-rw-r-- 35000 3500    3120 Oct 06 15:00:05 2014 ./00/THE_FILE_INSIDE_ARCHIVE_WHICH_CONTAINS_WHAT_YOU_ARE_SEARCHIG_FOR

How to display the archives which have files with a specific text inside:

root@aix:~# ls archives*.tar.Z
archives_20141007.tar.Z
archives_20141006.tar.Z
archives_20141009.tar.Z
root@aix:~# [color=green]./test.sh "archives*.tar.Z" WHAT_TO_SEARCH_FOR[/color]
archives_20141009.tar.Z
The script:
root@aix:~# cat test.sh
STRING=$2
FILE=$1

if [ -z  "$STRING" ]; then
        echo "What are you looking for?"
        exit 99
fi

for f in $(ls ${FILE});
        do
        zcat $f | tar -tvf - | grep ${STRING} >/dev/null 2>&1;
        RC=$?
        if [ $RC == 0 ]; then
        echo $f
        fi
done

How to remove all whitespace (including tabs) from the beginning of the line to the first word:

# echo "     Test, BABY!" | sed -e 's/^[ \t]*//'

How to change the extension on files in bulk with rename command:

# find . -name "*.php5" -exec rename -f 's/\.php5/.php/' {} \;

How to remove the extension on files in bulk with rename command:

# find . -name "*.php5" -exec rename -f 's/\.php5/.php/' {} \;

How to print field number X only on lines matching something, otherwise print field number Y with awk:

In this example below, as you can see, I am using the same awk command to print the field I want: virtual disk path
vbox@core:~$ vbm showvminfo irc | grep ^SATA | grep -v Empty
SATA (0, 0): /home/vbox/.VirtualBox/dynamic/irc/irc.vdi (UUID: 6e9e97ff-f312-45ca-8b3e-fa18b9032dd0)
vbox@core:~$ [color=green]vbm showvminfo irc | grep ^SATA | grep -v Empty | [/color][color=yellow]awk '/Controller/{print $5;next}{print $4}'[/color]
/home/vbox/.VirtualBox/dynamic/irc/irc.vdi

vbox@core:~$ vbm showvminfo egg | grep ^SATA | grep -v Empty
SATA Controller (0, 0): /home/vbox/.VirtualBox/dynamic/egg/egg.vdi (UUID: 6977dea1-e224-4d04-8649-b688baed2430)
SATA Controller (1, 0): /home/vbox/.VirtualBox/dynamic/egg/egg-swap.vdi (UUID: 5b039f89-ed53-4ce8-809b-9aeb84273b36)
vbox@core:~$ [color=green]vbm showvminfo egg | grep ^SATA | grep -v Empty | [/color][color=yellow]awk '/Controller/{print $5;next}{print $4}'[/color]
/home/vbox/.VirtualBox/dynamic/egg/egg.vdi
/home/vbox/.VirtualBox/dynamic/egg/egg-swap.vdi

How to find out which lines from one file are missing from another:

10:45:41 root@sonic:tmp# cat a
1
2
3
4
5
10:45:50 root@sonic:tmp# cat b
1
2
3
4
5
6
7
8
9
10
10:45:53 root@sonic:tmp# grep -F -v -x -f a b
6
7
8
9
10
  • Log in to post comments
  • 32728 views

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!
Or at least link back to this website.

Popular content

Today's:

  • PHP2Shell: Critical PHP Remote Code Execution Vulnerabilities
  • Drupal 7 to Drupal 10 Migration and Configuration Notes
  • How to test ethernet speed with iperf
  • Assetto Corsa Rally vs Real Life – La Bollène-Vésubie → Col de Turini | Monte-Carlo Rally
  • €6,000 MacBook Pro: Should I Throw It Away After 6 Years?
  • AIX FS Commands
  • CygWin World
  • CygWin Tips and Tricks
  • How to shrink a reiserfs LVM partition
  • ESXi: How to create a bootable USB installer of ESXi 7.0

All time:

  • Linux Networking: How to disable/enable offload features, RX/TX checksum, scatter, gather and beyond
  • Tivoli Storage Manager Client Commands (dsmc commands)
  • Centrify Useful Commands and Information
  • Run ZIM on OS X and create Zim.app
  • How to be sure network interfaces have always the same names
  • Linux backup/restore/reinstall
  • How to add exfat support on RHEL 6
  • Mafia II Joe's Adventures - Playboy Locations
  • HMC commands
  • Command Line Software Update in MacOS

Last viewed:

  • PHP2Shell: Critical PHP Remote Code Execution Vulnerabilities
  • How to shrink a reiserfs LVM partition
  • How to test ethernet speed with iperf
  • OS X - How to change audio output from Menubar
  • Linux: keepalive or not
  • The TCL 34R83Q is Insane! But There’s a Catch. Honest Review About a Real Product. Read Description.
  • Error: CarbonHeaders is an obsolete port. Please uninstall it.
  • Drupal 7 to Drupal 10 Migration and Configuration Notes
  • EA Sports WRC vs Assetto Corsa Rally | Visual Comparison in Ultra Wide (Gravel, Asphalt, Wet, Night, Snow)
  • ESXi: How to create a bootable USB installer of ESXi 7.0