Skip to content

Instantly share code, notes, and snippets.

@moonblade
Last active April 26, 2017 16:41
Show Gist options
  • Save moonblade/08d584066e54c2b03d738b72ffa6843d to your computer and use it in GitHub Desktop.
Save moonblade/08d584066e54c2b03d738b72ffa6843d to your computer and use it in GitHub Desktop.
print command for lab
#!/bin/bash
if [ -z $1 ]
then echo "PLEASE USE : p <rollNo>"
fi
# Get the current folder name, here it will be s13 or s14 etc
currentFolder=${PWD##*/}
# Input to the program will be a two digit roll number.
rollNumber=$1
# Full roll no is the roll number along with the folder, eg s1380
fullRollNumber=$currentFolder$rollNumber
# tempPrintFile is where the printing file is stored as a single file
tempPrintFile="/tmp/printFile"
# for each file 'f' in the print folder, do the following operations
echo "" > $tempPrintFile
for f in $fullRollNumber/print/*
do
# The following commands are done into a single file, concatinated in tmp folder
# To print userid and file as first line
(echo -e "\nUSERID : $fullRollNumber FILE : $f\n\n"
# Convert tabs to 4 spaces in the files and print it
sed 's/\t/ /g' $f
# Print a line break
echo -e "\f") >> $tempPrintFile
done
# print the current temporary print file
lp $tempPrintFile > /dev/lp0
@moonblade
Copy link
Author

Instructions: copy the file to /home/administrator/Desktop/p
run command as p <2 digit roll no> from inside s13 or s14 etc folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment