head_gedit, to check head of text files in gedit really quick (Ubuntu)
Recently I got some bit text files that I need to check the header of them and verify the format really quick. The traditional way is to go to command line, cd to this folder, then "head xxxx.txt".
Because I made "Mass Sequential Rename" script before, I know it doesn't take long to integrate "head" functionality into right-click of nautilus. Here is the result:
#!/bin/bash # Nautilus script for head and gedit. # Modified by Ben(AT)Fadshop.net. http://benincampus.blogspot.com .July 2, 2013 # Based on http://benincampus.blogspot.com/2009/03/mass-sequential-rename.html # save this file as ~/.gnome2/nautilus-scripts/head_gedit set -e IFS=$'\n' #for space in the file name. for FILE in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS do filename=""`basename "$FILE"`"" head "$FILE" > "/tmp/head_gedit_$filename" gedit "/tmp/head_gedit_$filename" rm "/tmp/head_gedit_$filename" done
Save the script as ~/.gnome2/nautilus-scripts/head_gedit , make it executable (chmod +x ~/.gnome2/nautilus-scripts/head_gedit) then in your nautilus, right click the text files you want to show (you can click multiple files!) and select "script - > head_gedit", you will see the heads of them showing in gedit instantly.
You can fine tune how many lines you want to show, or you can add a prompt to let user input a number by referring the "Mass Sequential Rename" script.
Have fun!
Labels: LINUX, Programming
0 Comments:
<< Home